Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(keyboard): improve keyboard hook with callback #831

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AntoineKM
Copy link
Contributor

@AntoineKM AntoineKM commented Apr 7, 2023

Checklist

  • Fix linting errors
  • Tests have been added / updated (or snapshots)

Change information

  • Uses React.useCallback to memoize the event handler function for better performance and to avoid unnecessary re-renders.
  • Adds all dependencies to the React.useCallback dependencies array to ensure that the function is correctly updated when any of its dependencies change.
  • Uses React.useEffect with a full dependency array to ensure that the event listener is correctly added and removed when the component mounts and unmounts, respectively (which wasn't the case before).
  • Adds default values to isCapture and elementEventType arguments of the elementBindingHandler function.

@netlify
Copy link

netlify bot commented Apr 7, 2023

Deploy Preview for geist-ui ready!

Name Link
🔨 Latest commit 1049c1a
🔍 Latest deploy log https://app.netlify.com/sites/geist-ui/deploys/642fe2f03977a80008b5e469
😎 Deploy Preview https://deploy-preview-831--geist-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@AntoineKM
Copy link
Contributor Author

Hey @unix can you give it a look ? 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant