question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useIsomorphicLayoutEffect flag set wrongly

See original GitHub issue

What 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:closed
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
timdorrcommented, Jan 8, 2020

image

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 a window 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.

1reaction
markeriksoncommented, Jan 7, 2020

It’s sad just how specific we’re having to feature-detect this.

Yeah, can you file a PR to add that change here?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found