AnimatePresent not unmounts component when using 'worklet'
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Current Behavior
Component remains in tree and not umounted after exit.
Expected Behavior
Component should be unmounted after exit
Steps To Reproduce
- Use
exit
prop with worklet
Versions
- Moti: 0.18.0
- Reanimated: 2.8.0
- React Native: 0.68.2
- Expo: 45.0.4
Screenshots
No response
Reproduction
function MyComponent() {
const forward = true
return (
<AnimatePresence custom={forward} initial={false}>
<MotiView
key={index}
style={[StyleSheet.absoluteFill, styles.content]}
from={forward ? ANIMATE_RT : ANIMATE_LT_STACK}
animate={{ translateX: 0 }}
// exit={{ opacity: 0 }} // <- with this component unmounts
exit={(custom) => {
'worklet'
// With 'worklet' exit components still exist in tree and proceed weird animations
return custom ? ANIMATE_LT_STACK : ANIMATE_RT
}}
transition={TRANSITION}
>
{arr[index]}
</MotiView>
</AnimatePresence>
)
}
const ANIMATE_RT = {
translateX: WIDTH,
zIndex: 10,
}
const ANIMATE_LT_STACK = { translateX: -WIDTH, zIndex: 5 }
const ANIMATE_LT = { translateX: -WIDTH }
const TRANSITION: TransitionConfig = {
type: 'timing',
duration: 2000,
easing: Easing.out(Easing.cubic),
}
const styles = StyleSheet.create({
content: {
overflow: 'hidden',
},
})
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:14 (9 by maintainers)
Top Results From Across the Web
[BUG] AnimatePresence won't unmount fastly changing content
Bug description: Hi, I'm using AnimatePresence to animate text that ... but will not unmount the component after the exit animation plays.
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 >why isnt my framer motion animation not triggering on unmount?
my loader component that I want to add the unmount animation to: import { motion } from 'framer-motion'; import React from ' ...
Read more >Animations — Tamagui Core
AnimatePresence animates direct children before they unmount. It's inspired by and forked from Framer Motion , but works with any animation in Tamagui....
Read more >framer-motion animate presence unmount - CodeSandbox
Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js.
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
nvm, i did it here https://github.com/nandorojo/moti/commit/6226c3e76f47077d2f634fe6355076471989dc85
chances are, there’s some other reason. is it an expensive component? AnimatePresence should only be used for simple animations usually, not for deeply-nested components