-
Notifications
You must be signed in to change notification settings - Fork 5
Calendar thinks it's in mobile when initially server side rendering #2
Comments
Hmmyeah. It's always going to either be wrong on mobile by default, or on desktop, with how it's currently done. Since the DOM is different between mobile and desktop. I think to remove the jump entirely, it'd have to only use CSS media queries to differ between the layouts |
It would never be 100% accurate, but I'm pretty sure parsing the useragent when it's rendering server-side would work for the vast majority of cases, haven't looked to see if/how that's possible yet with how it's setup though |
True. Could use https://www.npmjs.com/package/device, I think, in a getInitialProps() method: import device from 'device'
getInitialProps ({ req }) {
return { isMobileAgent: req && device(req.userAgent).is('mobile') }
} and then in the <Media query={mobileBreakpoint}>
{ matches => if (matches || isMobileAgent) ... }
</Media> I can give this a shot later tonight i think |
Awesome! That looks promising indeed. I am working on #4 at the moment so have at it if you want. |
Detect mobile browsers for server-side renders, closes #2
So the layout flips out a bit for a second on desktop until client-side React can reconcile it
The text was updated successfully, but these errors were encountered: