Commit 5587435
authored
## 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- packages/react-native-gesture-handler/src/v3/hooks/utils
1 file changed
+6
-0
lines changedLines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
81 | 87 | | |
82 | 88 | | |
83 | 89 | | |
| |||
0 commit comments