-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
setState getting into infinite loop #1784
Comments
I think this is a duplicate of #1783. |
cc @koba04 on this one too |
And actually, your case makes infinite loop even in react. Could you check it in the react sandbox? |
@Ailrun yep, infinite loop happening in React, when:
Fix for React: https://codesandbox.io/s/0mr5y064l
Nevetheless, after changing the type of component to What is "strange", is that I discover this by debugging why a test that has being working for a life, started to fail. |
IMO, then, your issue is about checking |
@artola componentDidMount() {
this.setState({value: false});
}
componentDidUpdate() {
this.setState({value: false});
} But this code would cause an inifinite loop with
I found an issue that enzyme doesn't handle PureComponent well. I'll fix it. |
The PR is #1786 |
A component that fires
setState
atcomponentDidMount
andcomponentDidUpdate
enters in an infinite loop. Here in a simplified example that produces this situation.Notice:
mount
also breaks.Interesting:
setState
with asetTimeout
WORKS.Example test:
With
"enzyme": "3.4.0"
and"enzyme": "3.4.1"
:With
"enzyme": "3.4.2"
:With
"enzyme": "3.4.3"
and"enzyme": "3.4.4"
:Expected behavior
No loop.
Additional context
"jest": "^23.5.0"
"react": "^16.4.2"
"enzyme": "3.4.4"
"enzyme-adapter-react-16": "^1.2.0"
The text was updated successfully, but these errors were encountered: