ResponsiveContext does not work with SSR
See original GitHub issuethe first ResponsiveContext.Consumer call is with size = undefined. When rendering server-side, the page does not know if it will be displayed for mobile or desktop - some components are visible or hidden while they shouldnt be and then on the first client-side render, the page updates with the correct screen size
One possible solution is to use User-Agent
and make an educated guess as to the screen size server-side so the initial render is correct.
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
react-responsive doesn't work with Server-side rendering
Show activity on this post. I am trying to use react-responsive to conditional rendering components base on device width. Everything worked ...
Read more >react-responsive doesn't work with Server-side rendering ...
Coding example for the question react-responsive doesn't work with Server-side ... import { Context as ResponsiveContext } from 'react-responsive'; .
Read more >react-responsive - npm
This is especially useful in a Node environment where these settings can't be detected (SSR) or for testing. Possible Keys. orientation , scan...
Read more >Responsive Context - Grommet
children. Render function that will be called with the current viewport size (e.g our base theme of size ...
Read more >npm:react-responsive-ssr | Skypack
Note: react-responsive-ssr has a peer dependency to react , react-dom , prop-types , react-responsive and mobile-detect , so don't forget to install those ......
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 FreeTop 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
Top GitHub Comments
We can use something like the bootstrap breakpoints sizes:
Phones - less than 768px Tablets - 768px to 992px Desktops - 992px to 1200px Large Desktops - 1200px and Up
i d’like to give this a go! seems interesting.