如何使用 react-spring 库为 React 组件设置动画取决于道具更新
我找到了这个https://codesandbox.io/s/xpqq0ll5nw并想用钩子实现同样的功能
const Counter = ({quantity}) => {
const animation = useSpring({
transform: 'scale(1)',
from: { transform: 'scale(1.2)' },
});
return (
<animated.span style={animation}">
{quantity}
</animated.span>
)
}