我不认为可以改变,但似乎可以调整速度stiffness and damping
,https://github.com/chenglou/react-motion/issues/265
您可以尝试帮助找出这些值,http://chenglou.github.io/react-motion/demos/demo5-spring-parameters-chooser/
在我看来,问题是挂载/卸载问题,但如果你不在乎,你可以设置mount
为假。
const Fade = ({
Style, on, mount, children
}) => {
const [animating, setAnimating] = useState(true)
const onRest = () => { setAnimating(false) }
useEffect(() => { setAnimating(true) }, [on])
if (mount) {
if (!on && !animating) {
return null
}
}
return (
<Style
on={on}
onRest={onRest}
>
{children}
</Style>
)
}
Fade.propTypes = {
Style: elementType,
on: bool,
mount: bool,
}