useIsomorphicLayoutEffect flag set wrongly
See original GitHub issueWhat is the current behavior?
useIsomorphicLayoutEffect
is set to true when running on a Node.js instance, where the window object is defined.
This is a common scenario when you need to emulate a subset of a web browser for tests or DOM manipulation, then you define the object perhaps with JSDom.
It’s resulting in console warnings and issues when hydrating the SSR code.
What is the expected behavior?
useIsomorphicLayoutEffect
flag is set to false when running in Node.js, always, not relying only on the window object being undefined.
Ref: https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js#L12
Used versions
react@16.8.4
react-redux@7.1.3
This used to work without issues, in react-redux@6.0.0
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
TypeError: (0 , _react.useEffect) is not a function - Stack Overflow
I was importing useLocation() from 'react' instead of from 'react-router-dom' . Rookie mistake, but it could happen to someone else, so I ...
Read more >useIsomorphicLayoutEffect() react hook - usehooks-ts
The React documentation says about useLayoutEffect : The signature is identical to useEffect, but it fires synchronously after all DOM mutations. That…
Read more >react-use | Yarn - Package Manager
useCopyToClipboard — copies text to clipboard. useDebounce — debounces a function. useError — error dispatcher. useFavicon — sets favicon of the page.
Read more >Netlify missing latest yarn versions? Yarn 3.2.X - Support
4:00:54 PM: warning " > gatsby-cypress@2.24.0" has incorrect peer dependency ... Have you tried setting the YARN_VERSION environment variable?
Read more >Blog - react-md
@react-md/layout: Added fixedAppBar flag into the useLayoutConfig ... This release is only to ensure that v2 is set to latest and has no...
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
If you’re defining
window
as a global, that’s going to potentially affect a large number of libs, not just React Redux. I don’t think what you’re doing is the “correct” way of creating a virtual DOM for your libraries.Over time, JSDOM is going to get closer and closer to the DOM spec, so things like the
innerWidth
value you’ve chosen will be implemented and fail as a check for our library. My biggest concern here is getting in an “arms race” over JSDOM’s spec implementation and our detection code. That is a losing battle for us, long term.Is it reasonable to make your code not rely on
window
being global? Can you create awindow
instance in a module that will ponyfill where it’s needed? That seems more sensible for your codebase anyways, and less likely to cause problems elsewhere.It’s sad just how specific we’re having to feature-detect this.
Yeah, can you file a PR to add that change here?