Skip to content
Discussion options

You must be logged in to vote

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:

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.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@MatiPl01
Comment options

@MatiPl01
Comment options

@Vimal1464
Comment options

@MatiPl01
Comment options

@Vimal1464
Comment options

Answer selected by MatiPl01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants