React native 如何从函数启动React本机可设置动画的动画?

React native 如何从函数启动React本机可设置动画的动画?,react-native,react-native-animatable,React Native,React Native Animatable,我刚刚开始学习React Native的可动画库,无法理解如何从函数启动动画 例如,我有: <Animatable.View animation={custom1}> <View style={styles.itemOne}> <Text>Hello World</Text> </View> </Animatable.View> 当然,当页面加载时,我的“custom1”动画会立即在视图上执行

我刚刚开始学习React Native的可动画库,无法理解如何从函数启动动画

例如,我有:

<Animatable.View animation={custom1}>
    <View style={styles.itemOne}>
       <Text>Hello World</Text>
    </View>
</Animatable.View>
当然,当页面加载时,我的“custom1”动画会立即在视图上执行

但是,如果我不希望在“调用”之前执行“custom1”动画(而不是在页面加载时),该怎么办?例如,如果我想做:

function initiateCustom1() {
   custom1.animate()
}

我该如何做到这一点?

我以为你在用这个

如果是,则可以使用
ref
prop

<Animatable.View
  animation='zoomInUp'
  ref={ref => {
    this.sample = ref;
  }}
>
  <Text>Sample</Text>
</Animatable.View>
<Animatable.View
  animation='zoomInUp'
  ref={ref => {
    this.sample = ref;
  }}
>
  <Text>Sample</Text>
</Animatable.View>
onPress={() => {
  this.sample.zoomOutDown();
  // or
  this.sample.zoomOutDown().then(() => {
    // do something after animation ends
  });
}}