generated at
useAnimatedStyle



イメージとしてはこういう風に書きたい
NG(tsx)
<Animated.View style={{ width: width += 50 }} />
が、 width useSharedValueで定義したもので、
↑のようにはかけないので、
代わりに、useAnimatedStyleを使って以下のように書く
ts
export default function App() { const translateX = useSharedValue<number>(0); const handlePress = () => { translateX.value += 50; }; const animatedStyles = useAnimatedStyle(() => ({ transform: [{ translateX: withSpring(translateX.value * 2) }], })); return ( <> <Animated.View style={[styles.box, animatedStyles]} /> <View style={styles.container}> <Button onPress={handlePress} title="Click me" /> </View> </> );