Commit b18935a
authored
[Web] Config refactor - update logic and drop class field (#3673)
## Description
This PR changes how config is handled on web, following #3658 it
separates update and set functionality, which allows passing only
relevant, changed fields to update, as opposed to the entire config.
Moreover it removes the config field from `GestureHandler` - adds
necessary fields as class fields, this mimics how config is handled on
iOS / Android and simplifies the code (previously some fields were both
both config and class fields).
## Test plan
The update functionality was tested on the following code.
```ts
import * as React from 'react';
import { Animated, Button } from 'react-native';
import { useSharedValue } from 'react-native-reanimated';
import {
GestureHandlerRootView,
NativeDetector,
useGesture,
} from 'react-native-gesture-handler';
export default function App() {
const [visible, setVisible] = React.useState(true);
const taps = useSharedValue(2);
const gesture = useGesture('TapGestureHandler', {
onEnd: () => {
console.log('Tap detected. Required number of taps:', taps.value);
taps.set(taps.value + 1);
},
numberOfTaps: taps,
});
return (
<GestureHandlerRootView
style={{ flex: 1, backgroundColor: 'white', paddingTop: 8 }}>
<Button
title="Toggle visibility"
onPress={() => {
setVisible(!visible);
}}
/>
{visible && (
<NativeDetector gesture={gesture}>
<Animated.View
style={[
{
width: 150,
height: 150,
backgroundColor: 'blue',
opacity: 0.5,
borderWidth: 10,
borderColor: 'green',
marginTop: 20,
marginLeft: 40,
},
]}
/>
</NativeDetector>
)}
</GestureHandlerRootView>
);
}
```1 parent 87c33d9 commit b18935a
File tree
11 files changed
+295
-284
lines changed- packages/react-native-gesture-handler/src
- web
- handlers
- tools
11 files changed
+295
-284
lines changedLines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | | - | |
85 | | - | |
| 84 | + | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
Lines changed: 7 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
37 | 34 | | |
38 | 35 | | |
39 | | - | |
40 | | - | |
| 36 | + | |
| 37 | + | |
41 | 38 | | |
42 | 39 | | |
43 | 40 | | |
| |||
0 commit comments