React-native-reanimated: V2: useAnimatedProps

Created on 15 Jun 2020  路  3Comments  路  Source: software-mansion/react-native-reanimated

Description

I noticed useAnimatedProps hook used in reanimated V2 liquid swipe example and nothing in documentation about it. As the name suggests, is it used for the props that are updating, am I right? or it is only for the animated components that are created using createAnimatedComponent?

馃彔 Reanimated2 馃documentation

Most helpful comment

It's to animated props which are not style props. for instance

 const props = useAnimatedProps(() => {
    return {
      strokeDashoffset: theta.value * radius,
    };
  });
  return (
    <Svg style={StyleSheet.absoluteFill}>
      <AnimatedCircle
        animatedProps={props}
        cx={r}
        cy={r}
        fill="transparent"
        r={radius}
        stroke={StyleGuide.palette.primary}
        strokeDasharray={`${circumference}, ${circumference}`}
        {...{ strokeWidth }}
      />
    </Svg>
  );

All 3 comments

It's to animated props which are not style props. for instance

 const props = useAnimatedProps(() => {
    return {
      strokeDashoffset: theta.value * radius,
    };
  });
  return (
    <Svg style={StyleSheet.absoluteFill}>
      <AnimatedCircle
        animatedProps={props}
        cx={r}
        cy={r}
        fill="transparent"
        r={radius}
        stroke={StyleGuide.palette.primary}
        strokeDasharray={`${circumference}, ${circumference}`}
        {...{ strokeWidth }}
      />
    </Svg>
  );

Thanks @wcandillon for your great example. Means a lot to me.

hey, thanks for letting us know. This is definitely an oversight and we will add this to the documentation soon

Was this page helpful?
0 / 5 - 0 ratings