Skip to content

Commit f04d434

Browse files
committed
Fixes
1 parent 9b4743a commit f04d434

4 files changed

Lines changed: 42 additions & 33 deletions

File tree

packages/react-native-gesture-handler/src/index.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,15 @@ export type {
7676
LegacyRectButtonProps,
7777
LegacyBorderlessButtonProps,
7878
} from './components/GestureButtonsProps';
79-
export type {
80-
RawButtonProps,
81-
BaseButtonProps,
82-
RectButtonProps,
83-
BorderlessButtonProps,
84-
} from './v3/components/GestureButtonsProps';
79+
8580
export {
8681
LegacyRawButton,
8782
LegacyBaseButton,
8883
LegacyRectButton,
8984
LegacyBorderlessButton,
9085
LegacyPureNativeButton,
9186
} from './components/GestureButtons';
92-
export {
93-
RawButton,
94-
BaseButton,
95-
RectButton,
96-
BorderlessButton,
97-
PureNativeButton,
98-
} from './v3/components/GestureButtons';
87+
9988
export type {
10089
TouchableHighlightProps,
10190
TouchableOpacityProps,
@@ -115,13 +104,7 @@ export {
115104
LegacyFlatList,
116105
LegacyRefreshControl,
117106
} from './components/GestureComponents';
118-
export {
119-
ScrollView,
120-
Switch,
121-
TextInput,
122-
FlatList,
123-
RefreshControl,
124-
} from './v3/components/GestureComponents';
107+
125108
export { Text } from './components/Text';
126109
export { HoverEffect } from './handlers/gestures/hoverGesture';
127110
export type {
@@ -184,4 +167,6 @@ export type { GestureTouchEvent as SingleGestureTouchEvent } from './handlers/ge
184167

185168
export * from './v3/hooks/gestures';
186169

170+
export * from './v3/components';
171+
187172
initialize();

packages/react-native-gesture-handler/src/v3/components/GestureComponents.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React, {
22
PropsWithChildren,
3-
ForwardedRef,
4-
RefAttributes,
53
ReactElement,
64
useRef,
75
useImperativeHandle,
86
useState,
7+
RefObject,
98
} from 'react';
109
import {
1110
ScrollView as RNScrollView,
@@ -111,9 +110,9 @@ export const TextInput = createNativeWrapper<RNTextInputProps>(RNTextInput);
111110
// eslint-disable-next-line @typescript-eslint/no-redeclare
112111
export type TextInput = typeof TextInput & RNTextInput;
113112

114-
type ImperativeFlatListRef =
113+
export type ImperativeFlatListRef<T = any> =
115114
| (ComponentWrapperRef<RNScrollViewProps> & {
116-
flatListRef: React.RefObject<FlatList<unknown>>;
115+
flatListRef: FlatList<T> | null;
117116
})
118117
| null;
119118

@@ -125,7 +124,7 @@ export const FlatList = ((props) => {
125124
);
126125

127126
const wrapperRef = useRef<ImperativeScrollViewRef>(null);
128-
const flatListRef = useRef<FlatList<unknown>>(null);
127+
const flatListRef = useRef<FlatList<any>>(null);
129128

130129
const flatListProps = {};
131130
const scrollViewProps = {};
@@ -185,11 +184,11 @@ export const FlatList = ((props) => {
185184
);
186185
}) as <ItemT = any>(
187186
props: PropsWithChildren<
188-
Omit<RNFlatListProps<ItemT>, 'renderScrollComponent'> &
189-
RefAttributes<FlatList<ItemT>> &
190-
NativeWrapperProperties
191-
>,
192-
ref?: ForwardedRef<FlatList<ItemT>>
187+
Omit<RNFlatListProps<ItemT>, 'renderScrollComponent' | 'ref'> &
188+
NativeWrapperProperties & {
189+
ref?: RefObject<ImperativeFlatListRef<ItemT>>;
190+
}
191+
>
193192
) => ReactElement | null;
194193
// eslint-disable-next-line @typescript-eslint/no-redeclare
195194
export type FlatList<ItemT = any> = typeof FlatList & RNFlatList<ItemT>;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export type {
2+
RawButtonProps,
3+
BaseButtonProps,
4+
RectButtonProps,
5+
BorderlessButtonProps,
6+
} from './GestureButtonsProps';
7+
8+
export {
9+
RawButton,
10+
BaseButton,
11+
RectButton,
12+
BorderlessButton,
13+
PureNativeButton,
14+
} from './GestureButtons';
15+
16+
export {
17+
ScrollView,
18+
Switch,
19+
TextInput,
20+
FlatList,
21+
RefreshControl,
22+
} from './GestureComponents';
23+
24+
export type { ImperativeFlatListRef as GHFlatListRef } from './GestureComponents';

packages/react-native-gesture-handler/src/v3/createNativeWrapper.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { DetectorType, InterceptingGestureDetector } from './detectors';
99
import { VirtualDetector } from './detectors/VirtualDetector/VirtualDetector';
1010

1111
export type ComponentWrapperRef<P> = {
12-
componentRef: React.ComponentType<P>;
13-
gestureRef: NativeGesture;
12+
componentRef?: React.ComponentType<P>;
13+
gestureRef?: NativeGesture;
1414
};
1515

1616
export default function createNativeWrapper<P>(
@@ -47,13 +47,14 @@ export default function createNativeWrapper<P>(
4747
const native = useNativeGesture(gestureHandlerProps);
4848

4949
const componentRef = useRef<React.ComponentType<P>>(null);
50+
const gestureRef = useRef<NativeGesture>(native);
5051

5152
useImperativeHandle(
5253
props.ref,
5354
() =>
5455
({
5556
componentRef: componentRef.current,
56-
gestureRef: native,
57+
gestureRef: gestureRef.current,
5758
}) as ComponentWrapperRef<P>
5859
);
5960

0 commit comments

Comments
 (0)