Skip to content

Commit 5587435

Browse files
authored
Add Pan offset props to PropsToFilter (#4026)
## Description In `Pan` gesture, offset properties are handled differently than other props. Before they're sent to native side, they are mapped to separate `start` and `end` offset properties. This happens when offset props are present. However, if one explicitly sets value of offset property to `undefined`, e.g.: ```ts activeOffsetY: Platform.OS === 'android' ? [-75, 75] : undefined, ``` the following warning can be observed: ``` WARN [react-native-gesture-handler] activeOffsetY is not a valid property for PanGestureHandler and will be ignored. ``` This PR adds offset properties to our filter. With this change, warning no longer appears. Fixes #4021 > [!NOTE] > It could also be solved by dynamically deleting `undefined` fields from config, but simply ignoring them sounds safer. ## Test plan <details> <summary>Tested on the following code:</summary> ```tsx import React from 'react'; import { StyleSheet, Text, View, Platform } from 'react-native'; import { usePanGesture } from 'react-native-gesture-handler'; export default function EmptyExample() { const panGesture = usePanGesture({ activeOffsetY: Platform.OS === 'android' ? [-75, 75] : undefined, }); return ( <View style={styles.container}> <Text style={{ fontSize: 64, opacity: 0.25 }}>😞</Text> <Text style={{ fontSize: 24, opacity: 0.25 }}>It's so empty here</Text> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, }); ``` </details>
1 parent c173e17 commit 5587435

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/react-native-gesture-handler/src/v3/hooks/utils/propsWhiteList.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ export const PropsToFilter = new Set<
7878
'shouldUseReanimatedDetector',
7979
'useAnimated',
8080
'runOnJS',
81+
82+
// Pan offset props before remapping:
83+
'activeOffsetY',
84+
'failOffsetX',
85+
'failOffsetY',
86+
'activeOffsetX',
8187
]);
8288

8389
export const PropsWhiteLists = new Map<

0 commit comments

Comments
 (0)