Detecting device type (i.e mobile, desktop or tablet on initial render in static pages) #13009
Unanswered
raghav0622
asked this question in
Help
Replies: 1 comment 1 reply
-
You could detect if the animation has run already when the component mounts and prevent it from replaying on the client. Something like https://joshwcomeau.com/snippets/react-hooks/use-has-mounted is a nice reusable hook for telling when a component has mounted, and you can use the output to determine if an animation should run. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It is possible to parse request headers in app.getInitialProps to detect device type but it makes all pages ssr which is pitfall.
I want device-specific layout (possible with ssr), also possible with static gneration but there are certain animations and styles that render on first render and then client-side code kicks in and renders again which is bad for module splitting and ux.
Any Ideas?
Beta Was this translation helpful? Give feedback.
All reactions