我有一个 TextView fadeOutDown 旧数据和 fadeInDown react-native-animatable 图书馆和已经设法做了一个动画,但不知道如何做两个。
TextView
fadeOutDown
fadeInDown
react-native-animatable
<Animatable.View animation={this.props.animation} style = {styles.innerView2}> <Text text = "abcd" style = {{alignItems: 'flex-start', width: DEVICE_WIDTH - 20, textAlign: 'left'}}/> </Animatable.View>
分配 ref 到可设置动画的组件,然后例如 componentDidUpdate ,可以重新触发动画
ref
componentDidUpdate
componentDidUpdate() { if (this.view !== undefined && this.view !== null) { this.view.fadeIn(1000); } } <Animatable.View ref={ref => (this.view = ref)} animation="fadeIn" easing="ease-in"> <Text>{this.state.newText}</Text> </Animatable.View>
这里有一个 snack