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