-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
useIsomorphicLayoutEffect check is incorrect in Jest + jsdom #1402
Comments
I believe the suggestion that's come up is to define your Jest test environment as Ultimately, there's only so much we can do here. React insists on logging this warning. We've done our best to feature-detect and work around it. If you've got any suggestions for improving the behavior, I'm absolutely interested. Beyond that, we've got our best attempt at a solution in place already. |
I looked around online and didn’t find anything like that. Could we add it to the docs or a FAQ somewhere? |
The primary issue discussing the facebook/react#14927 (comment) And yeah, go ahead and file a PR to mention that in the "Troubleshooting" docs page (which we really need to update anyway). |
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
I'm trying to test a Redux-connected React component. Whenever I run the test, I get the following warning:
The warning comes from React-DOM.
React-Redux is aware of the issue and defines
useIsomorphicLayoutEffect
based on the presence ofwindow.document.createElement
. In a normal server-side-rendering environment, that check works great.But in a test environment, jsdom defines
global.window.document.createElement
, so React-Redux's check causes it to useuseLayoutEffect
, causing the warning.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to a CodeSandbox (https://codesandbox.io/s/new) or RN Snack (https://snack.expo.io/) example below:
What is the expected behavior?
useIsomorphicLayoutEffect
isuseEffect
in a jest test.Which versions of React, ReactDOM/React Native, Redux, and React Redux are you using? Which browser and OS are affected by this issue? Did this work in previous versions of React Redux?
react@16.8.6
react-dom@16.8.6
redux@4.0.1
react-redux@7.1.0
jest@24.5.0
jest-environment-jsdom@24.5.0
jsdom@11.12.0
The text was updated successfully, but these errors were encountered: