Add matchMedia listener based alternative to Hide component
See original GitHub issueBased on some discussions with @sdalonzo, it might make sense to include an alternative to the Hide component that would allow for conditional rendering based on media query, rather than relying on CSS display: none
. This might make use of the context API to use a global listener and context consumers to control rendering.
Other libraries for reference:
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
addListener is deprecated. What's the alternative?
It works nicely but the addListener event handler is crossed out in VSC and I get the warning that it's deprecated.
Read more >Working with JavaScript Media Queries | CSS-Tricks
Using matchMedia(). To determine if the document matches the media query string in JavaScript, we use the matchMedia() method. Even though it's ...
Read more >Media Queries in JS - DEV Community
matchMedia is a method provided by window that can determine whether the given media query matches the current state of the browser. matchMedia....
Read more >The underestimated power behind matchMedia - EnmaScript
Let's see a code example that demonstrates how to add a listener/sensor (taken from the documentation): const consoleLogger = () => console. ...
Read more >MediaQueryList.addListener() - Web APIs - MDN Web Docs
A function or function reference representing the callback function you want to run when the media query status changes. Return value. None ( ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We’ve been specifically dealing with the fallout of hydration failures when SSR markup doesn’t match initial client renders. React’s docs specifically calls it out as an error when the markup doesn’t match. React 16 doesn’t throw out the current tree and completely re-render, but tries to patch it up instead… it can lead to some challenges.
We’re taking sort of a hybrid approach, but most everything relies on
display: none
. We have a wrapper component that we can flag certain breakpoints to do conditional rendering. It’s a big process, but we’re hoping to launch it to production soon. Once we do maybe we can pop back in and share our learnings.Hey folks! I forgot to follow up with this, but we recently published a blogpost on our experiences with responsiveness/react and some of the challenges we ran into (especially around server side rendering).
Feel free to check it out and shoot us questions if you have any: https://artsy.github.io/blog/2019/05/24/server-rendering-responsively/