Im trying to trigger an animation from the useEffect() hook, It has a dependency so that it doesn't loop.
this is what gets called inside useEffect
const toggleDrawerAnimation=()=>{
console.log('started next animation')
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
setDrawerPosition(drawerPosition === "bottom" ? "top" : "bottom")
};
// and a snippet of my drawer component
<View style={[styles.optionsMenuContainer,drawerPosition === "bottom"? null: styles.fading ]}>
The animation does work, but it's instant.
I tried calling the same code but using a buttonPress instead of useEffect(), and it does animate smoothly.
this has been kicking my butt. whats the issue? thanks for your help.
edit: here is my useEffect code block
useEffect(()=>{
if (init){
console.log('first render')
setInit(false)
}
else{
console.log('second render')
toggleDrawerAnimation()
}
},[init])