Warning: useLayoutEffect does nothing on the server, because its effect cannot […]
See original GitHub issueVersion 4 of <ButtonBase>
now incorporates useLayoutEffect()
in the src code here. This wasn’t present in version 3.
I understand the need for it however every jest test for a component that has a <Button>
within it now results in console warnings like so:
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://fb.me/react-uselayouteffect-ssr for common fixes.
in ForwardRef(ButtonBase)
in WithStyles(ForwardRef(ButtonBase))
in ForwardRef(Button)
in WithStyles(ForwardRef(Button)) (at ButtonWithIcon/index.tsx:57)
in Layout (at ButtonWithIcon/index.tsx:26)
in ButtonWithIcon (at OAuthButton/index.tsx:58)
in Layout (at OAuthButton/index.tsx:21)
in OAuthButton (at OAuthSignUp.tsx:221)
in div (at OAuthSignUp.tsx:200)
in Layout (at OAuthSignUp.tsx:138)
in OAuthSignUp (at OAuthSignUp.unit.test.tsx:60)
in Context.Provider
in ThemeProvider (at testProviders.tsx:29)
in Context.Provider (at store.tsx:36)
in Provider (at testProviders.tsx:28)
in Providers (at OAuthSignUp.unit.test.tsx:59)
The tests still pass as it’s just a warning, but is there any way to prevent these warning messages from appearing? I literally can’t even see all the warnings in my terminal as there are so many.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:31
- Comments:53 (38 by maintainers)
Top Results From Across the Web
How to fix the "Warning: useLayoutEffect does nothing on the ...
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >useLayoutEffect does nothing on the server · Issue #6 - GitHub
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >useLayoutEffect and SSR - Medium
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >useLayoutEffect and the warning on SSR - Eight Bites
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
Read more >useIsomorphicLayoutEffect() react hook - usehooks-ts
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format.
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
Ok found it. We can close this issue. You can reproduce the problem without Material-UI:
The problem is that
next-with-apollo
traverse the tree, by default, on the browser with the server side API:I have used Apollo extensively for more than a year at onepixel.com. I would be cautious with it, it can be slow at scale, it was our bottleneck n°1 from a performance perspective (graphql + apollo client). I believe you don’t need to traverse the React tree with the server side API on the client when switching routes. You can have loaders or a centralized getInitialProps logic instead.
@oliviertassinari yeah, totally. Thats would be great!