我正在尝试<BaseButton>
在按下时为视图设置动画。我想使用Reanimated
v1 native Animated.event
。我做了以下事情:
import Reanimated from 'react-native-reanimated';
const handleStateChanged = Reanimated.event([{ nativeEvent: { state } }]);
return (
<BaseButton
onHandlerStateChange={handleStateChanged}
onPress={() => alert('pressed')}
>
<Reanimated.View style={{}}><Text>Press me</Text></Reanimated.View>
</BaseButton>
)
但是我不断收到错误消息:
TypeError: _this.props.onHandlerStateChange 不是函数。(在'_this.props.onHandlerStateChange(e)'中,'_this.props.onHandlerStateChange'是AnimatedEvent的一个实例)
react-native-gesture-handler 文档明确指出我可以传入Animated.event
/Reanimated.event
而不是回调 - https://docs.swmansion.com/react-native-gesture-handler/docs/api/gesture-handlers/common- gh#onhandlerstatechange
关于如何解决这个问题的任何想法?