-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
useWindowSize callback #915
Comments
Keen to take this on 😄
|
@morgsmccauley great, its all yours!
Would be useful to return its state, i.e
Maybe we can use |
I'll try draft something up 👍 |
Just trying to understand things a little more:
Will appreciate any answers to these! 😄 |
If you want to do something with the window size, like some side-effect of pass the state to parent component, now you have to use const {width, height} = useWindowSize();
useEffect(() => {
// ...
}, [width, height]); with a callback it would be more direct: const {width, height} = useWindowSize({
onChange: (width, height) => {
// ...
},
});
Would need to see the code for that. |
I’ve implemented the callback feature. Now, users can pass a callback to handle window size changes directly. PR: #2608 Looking forward to your feedback! |
…onChange feat: add onChange callback to useWindowSize (#915)
Add ability to trigger a callback when the size is updated.
The text was updated successfully, but these errors were encountered: