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: rewrite useBreakpoint #862

Merged
merged 1 commit into from
Dec 5, 2020
Merged

Conversation

tremby
Copy link
Contributor

@tremby tremby commented Dec 5, 2020

This changeset rewrites useBreakpoint and fixes #860.

The hook now returns either a boolean or null; null in the case where window doesn't exist and so whether or not the query matches is unknown. It now no longer sets a resize handler on window, instead using the change event of the media query list. This is much more efficient.

I honestly don't know exactly what in the old version was causing the bug, but it's definitely fixed with this new version!

Note that I have never used Emotion, and have not tested the emotion version here. But given that the old version of the React one was identical to the old version of the Emotion one other than one of the require lines at the top, I expect it to be fine.

@tremby
Copy link
Contributor Author

tremby commented Dec 5, 2020

I see it has failed a size limit by 8 bytes. Given how arbitrary the 1.18K limit seems, I'm going to assume you won't need me to find 8 bytes to trim. Do I increase the limit in package.json as part of this commit, or how do you want me to proceed?

@mg901
Copy link
Owner

mg901 commented Dec 5, 2020

@tremby, нello! Thank you very much for the help! Yes, you can increase the limit.

@mg901
Copy link
Owner

mg901 commented Dec 5, 2020

@tremby, sorry, I can't answer quickly right now. I am sick of covid-19. Today I will check everything during the day. To be clear, I have no experience with SSR and didn't even think about possible problems.

@mg901 mg901 merged commit 3947016 into mg901:master Dec 5, 2020
github-actions bot pushed a commit that referenced this pull request Dec 5, 2020
## [9.0.6](v9.0.5...v9.0.6) (2020-12-05)

### Bug Fixes

* rewrite useBreakpoint ([#862](#862)) ([3947016](3947016))
@github-actions
Copy link

github-actions bot commented Dec 5, 2020

🎉 This PR is included in version 9.0.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tremby
Copy link
Contributor Author

tremby commented Dec 5, 2020

Ouch; I wish you a speedy recovery.

Thanks for merging this. Though it seems like I was too hasty when I said the problem was totally solved. Another pull request incoming...

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

Successfully merging this pull request may close these issues.

useBreakpoint issues with SSR (eg Next.js)
2 participants