AnimatePresence - exit not happening
See original GitHub issueDescribe the bug
exit
animation not happening with AnimatePresence
.
To Reproduce
The following is my code (redacted):
{list.map(item => (
<AnimatePresence>
<motion.div
initial={{opacity: 0}}
animate={{opacity: 1}}
exit={{opacity: 0}}
>
<MyComponent
key={item.id}
item={item}
/>
</motion.div>
</AnimatePresence>
))}
This is pretty much exactly like the example found here: https://www.framer.com/api/motion/examples/#exit-animations
Expected behavior
I expect MyComponent
to fade out when it’s item
is removed from list
. It does not. It just disappears.
Desktop (please complete the following information):
- OS: OSX 10.13.6
- Browser Chrome
- Version 76.0.3809.100
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
Animate Presence exit not working framer motion
The reason that this is not working is that you have to explicitly specify the key of the child that you are conditionally...
Read more >AnimatePresence exit not working for me... · Issue #493 - GitHub
Dunno if this is a bug or if i'm doing something wrong, but the exit prop does not seem to be working for...
Read more >Framer Motion exit animation is not working : r/reactjs - Reddit
Hello, I am trying to use framer-motion and want to animate an exit, this is how I am defining the motion div: {isOpen(point)...
Read more >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 >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 >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
Would you be able to elaborate on that point? I’m not clear why the motion.div elements are not being removed from the tree when the route which is visible changes
AnimatePresence should wrap the list otherwise it gets unmounted along with the item.