-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Infinite Loop when maximum update depth exceeds #11136
Comments
Hey, @anushreesubramani! Thanks for the report. I ran the snippet you provided and it seems like it's stopping after the maximum update depth error: https://jsfiddle.net/xonsuqwz/ Can you verify if that JSFiddle is working as expected for you? If so, how does it differ from the code you're running to get the infinite loop? |
JSFiddle might work differently. It's worth checking locally. |
@gaearon I tested locally with the HTML file below and saw the same results in Chrome for both the production and development builds <!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="container"></div>
<script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
<script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>
<script>
class App extends React.Component {
constructor() {
super();
this.state = {
value: null,
};
}
render() {
this.setState({
value: 'test',
});
return React.createElement('div', null);
}
}
ReactDOM.render(
React.createElement(App, null),
document.getElementById('container')
);
</script>
</body>
</html> |
This could also be specific to CRA environment. |
Yes please. Although let's keep this one open too for posterity. |
i have opened an issue in CRA for the same. https://github.com/facebookincubator/create-react-app/issues/3251 |
Was fixed inside CRA. |
I am still getting this error. |
I am still getting the error with React 16.2.0. setState does not called in "componentWillUpdate" or "componentDidUpdate". nestedUpdateCount incremented to 1001. |
Hey folks—just to chime in, I'm still experiencing this in React 16.2 in production. It seems that in the JSFiddle above, the App component is unmounted once the invariant violation occurs. In my app, the component is not unmounted, and anything that calls I've verified this by creating a component like the JSFiddle one that triggers a "Maximum call depth" exception exactly once and then stops. Any subsequent I can certainly unmount / remount the React root (or maybe I need an error boundary and don't have one), but I think it'd be super great if the error description identified this could happen. I spent a long time looking at those downstream setState calls triggering a "Maximum call depth" error and trying to figure out how on earth they were looping 1000+ times :-) |
If you think there's a React bug here please file a new issue with a reproducing example. Thanks. |
@gaearon thanks—I created a Fiddle to file an issue (https://jsfiddle.net/ts8zbh4u/) but it looks like the problem I was encountering has been fixed already in React 16.6. 🎉 In 16.2, the "Maximum call depth" error triggered via a |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
I wrote this component to recreate the warnings from #11081 and to fix it:
And in the process found that this error came up:
But the execution did not stop. It was going in an infinite loop and printing 2 variants of the same error one after another.
Screenshot for your reference:
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).
Snippet given above
What is the expected behavior?
There shouldn't be an infinite loop. The execution should stop after printing the error.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16, Chrome 59, Ubuntu. I tested it in older versions of react and this problem is not present there.
The text was updated successfully, but these errors were encountered: