Closed weirenxue closed 2 months ago
This isn't a Redux core issue, and it presumably isn't an issue with Redux or React-Redux at all. Setting state in a useEffect
should be only be done rarely and with caution:
In general this looks like a very complicated and chained set of useEffect
s, I don't know what the actual purpose of this is, and it looks like it's contrived to cause a recurring series of React re-renders. This doesn't have anything to do with Redux.
Prior Issues
I did not find any existing issues or PRs that relate to this problem.
What is the current behavior?
I am encountering a "Maximum update depth exceeded" error in my React application when using Redux with useEffect. This issue occurs intermittently when clicking the "App1 click me" button. However, clicking the "App2 click me" button does not cause the error.
Steps to Reproduce
Add the following code to the application:
You can also reproduce the issue using this CodeSandbox link: https://codesandbox.io/p/sandbox/empty-forest-jz8whm
What is the expected behavior?
Redux should not cause a "Maximum update depth exceeded" error when using useEffect in this manner.
Environment Details
Redux version: ^9.1.2 Redux Toolkit version: ^2.2.7 React version: ^18.3.1 React DOM version: ^18.3.1 Browser: Edge OS: macOS 14.5