-
I have a simple component below with width useSharedValue
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
You aren't using the shared value properly. If you want to use reanimated shared values to style components, you would have to use the See this example: import Animated, { useAnimatedStyle, useSharedValue } from 'react-native-reanimated';
function Child() {
const width = useSharedValue(100);
const animatedStyle = useAnimatedStyle(() => ({
width: width.value
});
return (
<View>
<Button>Click</Button>
<Animated.View style={animatedStyle} />
</View>
);
} Please let me know if it fixes your issue. |
Beta Was this translation helpful? Give feedback.
You aren't using the shared value properly. If you want to use reanimated shared values to style components, you would have to use the
useAnimatedStyle
hook to create the animated style first, and then pass the resulting style to the component's style property.See this example:
Please let me know if it fixes your issue.