screens/CalendarScreen.js
import React, {useRef, useState, useEffect} from 'react'; import {Animated, Button, StyleSheet, View} from 'react-native'; function () { const animation (new Animated.Value(1)).current; const [hidden, setHidden] = useState(false); useEffect(() => { Animated.timing(animation, { toValue: hidden ? 0 : 1, useNativeDriver: true, }).start(); }, [hidden, animation]); return ( <View> <Animated.View style={[ styles.rectangle, { opacity: animation, }, ]} /> <Button title="Toggle" onPress={() => { setHidden(!hidden); }} /> </View> ); } ( )