我无法在渲染器上显示动画的值并返回此错误。
不变违规:对象作为 React 子对象无效(发现:带有键 {value} 的对象)。如果您打算渲染子集合,请改用数组。
当然,我看到了其中的价值console
constructor(props) {
super(props);
this.state={
progress:0
}
this.animatedValue = new Animated.Value(0);
this.animatedValue.addListener((progress) => {
this.setState({progress})
});
}
componentDidMount() {
this.animate()
}
animate() {
this.animatedValue.setValue(0);
Animated.timing(
this.animatedValue,
{
toValue: 1,
duration: 15000,
easing: Easing.linear
}
).start()
}
render() {
return(
<View>
<Text> {this.state.progress} </Text>
</View>
);
}
赋予的函数addListener
将使用带有 a 的对象来调用value
key 作为参数,所以而不是设置progress
对于整个对象,使用value
反而:
this.animatedValue.addListener((progress) => {
this.setState({ progress: progress.value });
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)