1- import * as React from 'react' ;
2- import {
1+ import React , {
32 PropsWithChildren ,
43 ForwardedRef ,
54 RefAttributes ,
65 ReactElement ,
6+ useRef ,
7+ useImperativeHandle ,
8+ useState ,
79} from 'react' ;
810import {
911 ScrollView as RNScrollView ,
@@ -23,12 +25,8 @@ import createNativeWrapper, {
2325
2426import { NativeWrapperProperties } from '../types/NativeWrapperType' ;
2527import { NativeWrapperProps } from '../hooks/utils' ;
26- import { Gesture } from '../types' ;
2728import { DetectorType } from '../detectors' ;
28- import {
29- NativeViewGestureConfig ,
30- NativeViewHandlerData ,
31- } from '../hooks/gestures/native/useNativeGesture' ;
29+ import { NativeGesture } from '../hooks/gestures/native/useNativeGesture' ;
3230
3331export const RefreshControl = createNativeWrapper (
3432 RNRefreshControl ,
@@ -57,20 +55,19 @@ export const ScrollView = (
5755 props : RNScrollViewProps &
5856 NativeWrapperProperties & {
5957 ref ?: React . RefObject < ImperativeScrollViewRef > ;
60- // This prop existst because using `ref` in `renderScrollComponent` doesn't work.
58+ // This prop existst because using `ref` in `renderScrollComponent` doesn't work (it is overwritten by RN internals) .
6159 innerRef ?: ( node : ImperativeScrollViewRef ) => void ;
6260 }
6361) => {
6462 const { refreshControl, innerRef, ref, ...rest } = props ;
6563
66- const [ scrollGesture , setScrollGesture ] = React . useState < Gesture <
67- NativeViewHandlerData ,
68- NativeViewGestureConfig
69- > | null > ( null ) ;
64+ const [ scrollGesture , setScrollGesture ] = useState < NativeGesture | null > (
65+ null
66+ ) ;
7067
71- const wrapperRef = React . useRef < ComponentWrapperRef < RNScrollViewProps > > ( null ) ;
68+ const wrapperRef = useRef < ComponentWrapperRef < RNScrollViewProps > > ( null ) ;
7269
73- React . useImperativeHandle < ImperativeScrollViewRef , ImperativeScrollViewRef > (
70+ useImperativeHandle < ImperativeScrollViewRef , ImperativeScrollViewRef > (
7471 ref ,
7572 ( ) => wrapperRef . current
7673 ) ;
@@ -116,20 +113,19 @@ export type TextInput = typeof TextInput & RNTextInput;
116113
117114type ImperativeFlatListRef =
118115 | ( ComponentWrapperRef < RNScrollViewProps > & {
119- flatListRef : React . RefObject < FlatList < any > > ;
116+ flatListRef : React . RefObject < FlatList < unknown > > ;
120117 } )
121118 | null ;
122119
123120export const FlatList = ( ( props ) => {
124121 const { refreshControl, ref, ...rest } = props ;
125122
126- const [ scrollGesture , setScrollGesture ] = React . useState < Gesture <
127- NativeViewHandlerData ,
128- NativeViewGestureConfig
129- > | null > ( null ) ;
123+ const [ scrollGesture , setScrollGesture ] = useState < NativeGesture | null > (
124+ null
125+ ) ;
130126
131- const wrapperRef = React . useRef < ImperativeScrollViewRef > ( null ) ;
132- const flatListRef = React . useRef < FlatList < any > > ( null ) ;
127+ const wrapperRef = useRef < ImperativeScrollViewRef > ( null ) ;
128+ const flatListRef = useRef < FlatList < unknown > > ( null ) ;
133129
134130 const flatListProps = { } ;
135131 const scrollViewProps = { } ;
@@ -147,7 +143,7 @@ export const FlatList = ((props) => {
147143 }
148144 }
149145
150- React . useImperativeHandle < ImperativeFlatListRef , ImperativeFlatListRef > (
146+ useImperativeHandle < ImperativeFlatListRef , ImperativeFlatListRef > (
151147 // @ts -ignore We want to override ref
152148 ref ,
153149 ( ) => {
0 commit comments