【发布时间】:2018-07-03 18:25:58
【问题描述】:
我无法在 Render 上显示 Animated 的值并返回此错误。
Invariant Violation:对象作为 React 子级无效(发现:带有键 {value} 的对象)。如果您打算渲染一组子项,请改用数组。
当然,我在console中看到了Value
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>
);
}
【问题讨论】:
标签: javascript reactjs react-native