"Can't perform a React state update on an unmounted component" warning on React 16 #497
-
A "Can't perform a React state update on an unmounted component" warning is logged when a component is unmounted and has a snapshot in it. Here's a very simple repro: https://codesandbox.io/s/valtio-unmounted-component-error-reproduction-gp4vcv It only fails in React 16.14.0, which according to the github page it's supposed to work. If you update the sandbox to React 17 or higher the warning disappears. In this particular case there's the same snapshot in the parent and the child component. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
We'll be updating our app to React 17 which doesn't have almost any breaking change. I think the problem with React 16 might be related with this change: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing |
Beta Was this translation helpful? Give feedback.
-
I'm pretty sure that warning is a false positive in this case. (the warning is completely removed in react 18.) |
Beta Was this translation helpful? Give feedback.
I'm pretty sure that warning is a false positive in this case. (the warning is completely removed in react 18.)
updating to react 17 should be good as you say.