I've started react native project from scratch, installed react reanimated 1. I've pushed the repository: https://github.com/matiasmm/test-reanimated-gestures/tree/caf1af2e53605f19b466a27108ad408c95290707
I'm trying to test the pan event, but onGestureEvent
doesn't seem to trigger. The box doesn't move (I'm testing on android).
Even, If I replace
<PanGestureHandler onGestureEvent={onPanGestureEvent}>
by
<PanGestureHandler onGestureEvent={() => console.log("event called")}>
This console.log never executes ^
import React from 'react';
import { StyleSheet, View } from 'react-native';
import {PanGestureHandler} from 'react-native-gesture-handler';
import Reanimated from 'react-native-reanimated';
const _touchX = new Reanimated.Value(0);
const App: () => Node = () => {
const onPanGestureEvent = Reanimated.event(
[
{
nativeEvent: {
translationX: _touchX,
},
},
],
{
useNativeDriver: true,
},
)
return (
<View style={styles.container}>
<PanGestureHandler onGestureEvent={onPanGestureEvent}>
<Reanimated.View style={[styles.view, {transform: [{translateX: _touchX}]}]} />
</PanGestureHandler>
</View>
);
};
const styles = StyleSheet.create({
container: {
backgroundColor: 'gray',
flex: 1,
},
view: {
marginTop: 32,
paddingHorizontal: 24,
backgroundColor: 'red',
width: 200,
height: 200,
}
});
export default App;
I want to understand why the event is not triggering. What do I need to do to make the box to move when I pan on it.