小编Muh*_*eed的帖子

如何从 Reammited Value 中获取数值?

我使用 react native reanimated 创建了一个简单的动画,但我无法访问 Reanimated Value 的数值

我使用的是胜利本机饼图,我想制作一个简单的效果,饼角从 0 到 360,但我已经尝试过 react-native 动画 API,它可以很好地与添加侦听器配合使用,但我想使用重新动画来解决性能问题

我正在寻找的图表从 0 到 360 开始的动画效果

使用 react-native Animated API 正确运行:

const Chart = props => {
  const { data, width, height } = props;
  const endAngleAnimatedValue = new Value(0);
  const [endAngle, setEndAngle] = useState(0);
  const runTiming = Animated.timing(endAngleAnimatedValue, {
    duration: 1000,
    to: 360
  });

  useEffect(() => {
    endAngleAnimatedValue.addListener(_endAngle => setEndAngle(_endAngle));
    runTiming.start();
    return () => {
      endAngleAnimatedValue.removeAllListeners();
    };
  }, [endAngleAnimatedValue]);

  return (
    <VictoryPie
      data={data}
      width={width}
      height={height} …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native victory-charts react-native-reanimated

5
推荐指数
1
解决办法
453
查看次数