在最简单的例子中:
import {Motion, spring} from 'react-motion';
// In your render...
<Motion defaultStyle={{x: 0}} style={{x: spring(10)}}>
{value => <div>{value.x}</div>}
</Motion>
如果我在回调主体周围放置花括号,这对我有用:
import {Motion, spring} from 'react-motion';
// In your render...
<Motion defaultStyle={{x: 0}} style={{x: spring(10)}}>
{
(value) => { <div>{value.x}</div> }
}
</Motion>
我得到一个不变的违反。我误解了这里发生的事情吗?如果我在回调中显式返回元素,我不会得到不变的违反,但动画不起作用。