in my react native app I want to move a view down 100 pixels if mobx observable "isModalVisible" is true, then 100 pixels up when it changes to false.
How can I start an animation to a mobx state change?
How can I move down 100 pixels a view using react native animated?
This is my first time with react native animation so I haven't got an idea...
const [ translateValue, setTranslateValue] = useState(new Animated.Value(0));
<Animated.View style={{transform: [{translateY: translateValue}]}}></Animated.View>
Thanks in advance
React.useEffect(() => {
// do what you need to update the animation here //
}, [<MOBXSTATEVARIABLEHERE>]);
Animated.timing(myAnimationValue, {
toValue: 1 // (or whatever value you want Y to be here),
duration: 500
}).start();
const myAnimationValue = React.useRef(new Animated.Value(0)).current;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.