Commit aed7c4c
authored
[Web] Remove
## Description
This PR removes `invokeNullableMethod` function from `web`.
From what I've found, this function is no longer necessary and makes web
codebase less readable.
On web we only deal with functions. The only exception would be an
`Animated.event`, but this can be an object iff `useNativeDriver` is set
to `true`. However, [this is not supported on
`web`](https://necolas.github.io/react-native-web/docs/react-native-compatibility/?utm_source=openai).
Also, part of the function refers to the old Reanimated 1 API, which is
no longer supported.
My findings are that calling the method when it exists is enough. If
not, we are still in beta phase of v3 so we can bring it back if it
turns out that it was necessary.
## Test plan
Tested on expo example on web.
<details>
<summary>Tested on the following Animated.event example:</summary>
```tsx
import * as React from 'react';
import { Animated, Button } from 'react-native';
import {
GestureHandlerRootView,
GestureDetector,
usePanGesture,
} from 'react-native-gesture-handler';
function useAnimatedValue(
initialValue: number,
config?: Animated.AnimatedConfig
): Animated.Value {
const ref = React.useRef<null | Animated.Value>(null);
if (ref.current == null) {
ref.current = new Animated.Value(initialValue, config);
}
return ref.current;
}
export default function App() {
const [visible, setVisible] = React.useState(true);
const value = useAnimatedValue(0);
const event = Animated.event(
[{ nativeEvent: { handlerData: { translationX: value } } }],
{
useNativeDriver: true,
}
);
const gesture = usePanGesture({
onUpdate: event,
useAnimated: true,
});
return (
<GestureHandlerRootView
style={{ flex: 1, backgroundColor: 'white', paddingTop: 8 }}>
<Button
title="Toggle visibility"
onPress={() => {
setVisible(!visible);
}}
/>
{visible && (
<GestureDetector gesture={gesture}>
<Animated.View
style={[
{
width: 150,
height: 150,
backgroundColor: 'blue',
opacity: 0.5,
borderWidth: 10,
borderColor: 'green',
marginTop: 20,
marginLeft: 40,
},
{ transform: [{ translateX: value }] },
]}
/>
</GestureDetector>
)}
</GestureHandlerRootView>
);
}
```
</details>invokeNullableMethod (#4084)1 parent dac0e6a commit aed7c4c
1 file changed
Lines changed: 35 additions & 89 deletions
Lines changed: 35 additions & 89 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
404 | 404 | | |
405 | 405 | | |
406 | 406 | | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
414 | 414 | | |
415 | | - | |
| 415 | + | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| |||
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
452 | 452 | | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
465 | 466 | | |
466 | 467 | | |
467 | 468 | | |
| |||
672 | 673 | | |
673 | 674 | | |
674 | 675 | | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
679 | | - | |
680 | | - | |
681 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
682 | 683 | | |
683 | | - | |
| 684 | + | |
684 | 685 | | |
685 | 686 | | |
686 | 687 | | |
| |||
1082 | 1083 | | |
1083 | 1084 | | |
1084 | 1085 | | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
1104 | | - | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
1110 | | - | |
1111 | | - | |
1112 | | - | |
1113 | | - | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | | - | |
1134 | | - | |
1135 | | - | |
1136 | | - | |
1137 | | - | |
1138 | | - | |
1139 | | - | |
0 commit comments