[BUG] AnimationPresence exit only works on direct descendants
See original GitHub issue2. Describe the bug
Exit animation doesn’t work unless motion component is a direct descendant of AnimationPresence
3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
https://codesandbox.io/s/peaceful-margulis-lnc6b
4. Steps to reproduce
- Click the +/- buttons and the animations should work as expected.
- Then uncomment the lines 9 and 20
- Click the +/- buttons, the animation on mount works but the exit animation no longer works
5. Expected behavior
Exit animation to still work even if it’s not a direct descendent
7. Environment details
OS: macOs Catalina Browser: Chrome 78.0.3904.70
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
AnimatePresence | Framer for Developers
Exit animations. AnimatePresence works by detecting when direct children are removed from the React tree. Any motion components contained by the removed child ......
Read more >javascript - Animate presence not working in next js for exit ...
I'm trying to set an exit animation to my components in next js but I'm only able to give an initial animation. Can...
Read more >Advanced page transitions with Next.js and Framer Motion
One key point here is to make sure your animated elements are direct children of AnimatePresence so that it can take over and...
Read more >Collapsible table rows with Framer Motion layout animations
This is an unscripted chat & exploration of some different approaches for animating table rows, which are harder to animate than normal div ......
Read more >Updates
Animate Presence — Small update: exitBeforeEnter is now mode="wait" . ... for a bug; Animate Presence — Currently only partially works in overrides, ......
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
The documentation has an example that matches this use case, but it does not mention anything about the exit animation not working. The presence of the
exit
prop implies that it is possible to animate the exit transition of nested motion components.https://www.framer.com/api/motion/animate-presence/#animating-custom-components
This is as per design. By uncommenting those lines you give
AnimatePresence
a single child which is never added or removed.