withSpringを使用する
App.js
import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View, Button } from 'react-native';
import Animated, { useSharedValue, useAnimatedStyle, withSpring} from 'react-native-reanimated';
export default function App() {
const translateX = useSharedValue(0);
const handlePress = () => {
}
return (
<View style={styles.container}>
<Animated.View style={[styles.box, animatedStyle]}/>
<Button
title='PUSH'
onPress={handlePress}/>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
box: {
width: 100,
height: 100,
backgroundColor: 'violet',
}
});
*1:) => ({
}