[BUG] State update after AnimatePresence is unmouted
See original GitHub issueDescribe the bug
When an exit animation is running while the <AnimatePresence/>
component itself gets unmounted, you get an Can't perform a React state update on an unmounted component
error.
To Reproduce Steps to reproduce the behavior:
- Go to https://codesandbox.io/s/nice-vaughan-wcr1z
- Click on “Toggle Content”
- While the box is disappearing, click on “Toggle Container”
Expected behavior No state update should happen when the parent AnimatePresence is unmounted
Desktop (please complete the following information):
- OS: MacOS
- Browser: Chrome
- Version: latest
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6
Top Results From Across the Web
[BUG] AnimatePresence does not work under certain conditions
Although the hook won't be called after the component is unmounted from the perspective of React, if that hook returns a ref stored...
Read more >Framer-motion exit animation on unmounted component
Move the state up to the parent, update the card key to a consistent value between renders, and don't update the entire props...
Read more >Exit animation with `framer-motion` demystified
The final step is to re-render the AnimatePresence component when all the exit animation are finished to render the right React elements. After...
Read more >AnimatePresence | Framer for Developers
Notifies components when they're going to be unmounted and; Allows them to defer that unmounting until after an operation is complete (for instance...
Read more >Email client - Framer Motion Recipes - Build UI
Email client. Add animation to unmounting elements using the versatile AnimatePresence component. Framer Motion Recipes. 8 lessons · 03:08:13.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think i am still running into this issue even at 1.7.
https://codesandbox.io/s/blissful-cache-9mmh7
It looks like that’s indeed the the case. I’ve upgraded and no longer seeing those errors. Thanks for letting us know.