Commit 3f13c2a
authored
## Description
Since React 19, `useRef` requires initial value. In that case `null` is
common value, but unfortunately our types do not handle that case. This
PR fixes this problem.
## Test plan
`yarn ts-check`
<details>
<summary>Also tested on the following code:</summary>
```tsx
import React, { useRef } from 'react';
import {
View,
Text,
StyleSheet,
// ScrollView as RNScrollView,
} from 'react-native';
import {
Gesture,
GestureDetector,
GestureHandlerRootView,
ScrollView as GHScrollView,
} from 'react-native-gesture-handler';
const App = () => {
const scrollRef = useRef<GHScrollView>(null);
const swipe = Gesture.Pan()
.simultaneousWithExternalGesture(scrollRef)
.onUpdate((e) => {
console.log(e);
})
.onFinalize((e, s) => {
console.log(e, s);
})
.onEnd(() => {});
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<GestureDetector gesture={swipe}>
<View style={styles.container}>
<GHScrollView
horizontal
ref={scrollRef}
style={{ marginTop: 24, maxHeight: 60 }}
contentContainerStyle={{
alignItems: 'center',
paddingHorizontal: 16,
}}
showsHorizontalScrollIndicator={false}>
{Array.from({ length: 10 }).map((_, idx) => (
<View
key={idx}
style={{
width: 80,
height: 40,
backgroundColor: '#e0e0e0',
borderRadius: 8,
justifyContent: 'center',
alignItems: 'center',
marginRight: 12,
}}>
<Text>Item {idx + 1}</Text>
</View>
))}
</GHScrollView>
</View>
</GestureDetector>
</GestureHandlerRootView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
},
text: {
fontSize: 18,
color: '#333',
},
});
export default App;
```
</details>
1 parent 6c7481b commit 3f13c2a
File tree
1 file changed
+10
-4
lines changed- packages/react-native-gesture-handler/src/handlers/gestures
1 file changed
+10
-4
lines changedLines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
357 | 359 | | |
358 | 360 | | |
359 | 361 | | |
| |||
365 | 367 | | |
366 | 368 | | |
367 | 369 | | |
368 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
369 | 373 | | |
370 | 374 | | |
371 | 375 | | |
| |||
377 | 381 | | |
378 | 382 | | |
379 | 383 | | |
380 | | - | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
381 | 387 | | |
382 | 388 | | |
383 | 389 | | |
| |||
0 commit comments