Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 如何测试具有相同起点和终点的动画?_Reactjs_Jestjs_React Testing Library_React Spring - Fatal编程技术网

Reactjs 如何测试具有相同起点和终点的动画?

Reactjs 如何测试具有相同起点和终点的动画?,reactjs,jestjs,react-testing-library,react-spring,Reactjs,Jestjs,React Testing Library,React Spring,当animatedprop设置为true时,我有一个组件会“抖动”。这就是它的样子 const Shake = ({ animate, children, ...props }) => { const { x } = useSpring({ from: { x: 0 }, x: animate ? 1 : 0, config: { mass: 12, tension: 500, friction: 80 }, }); return ( <a

animated
prop设置为true时,我有一个组件会“抖动”。这就是它的样子

const Shake = ({ animate, children, ...props }) => {
  const { x } = useSpring({
    from: { x: 0 },
    x: animate ? 1 : 0,
    config: { mass: 12, tension: 500, friction: 80 },
  });
  return (
    <animated.div
      style={{
        transformOrigin: 'center center',
        transform: animate && x
          .interpolate({
            range: [0, 0.5, 1],
            output: [0, 2, 0],
          })
          .interpolate((x) => `rotate(${x}deg)`),
      }}
      {...props}
    >
      {children}
    </animated.div>
  );
};
可能是误报,因为动画甚至可能未被触发

这个动画是基于spring的,由react-spring提供动力,而不是基于时间,所以我不能确切地说动画的中间部分何时被触发

有人有办法解决这个问题吗

.toHaveStyle(`transform: rotate(0deg)`)