File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ import { DraggableFlatListProps } from "../types";
55import DraggableFlatList from "../components/DraggableFlatList" ;
66import { useNestableScrollContainerContext } from "../context/nestableScrollContainerContext" ;
77import { useNestedAutoScroll } from "../hooks/useNestedAutoScroll" ;
8+ import { FlatList } from "react-native-gesture-handler" ;
89
9- export function NestableDraggableFlatList < T > ( props : DraggableFlatListProps < T > ) {
10+ export function NestableDraggableFlatListInner < T > (
11+ props : DraggableFlatListProps < T > ,
12+ ref ?: React . ForwardedRef < FlatList < T > >
13+ ) {
1014 const hasSuppressedWarnings = useRef ( false ) ;
1115
1216 if ( ! hasSuppressedWarnings . current ) {
@@ -47,6 +51,7 @@ export function NestableDraggableFlatList<T>(props: DraggableFlatListProps<T>) {
4751 return (
4852 < Animated . View ref = { viewRef } onLayout = { onListContainerLayout } >
4953 < DraggableFlatList
54+ ref = { ref }
5055 activationDistance = { 20 }
5156 autoscrollSpeed = { 50 }
5257 scrollEnabled = { false }
@@ -71,3 +76,11 @@ export function NestableDraggableFlatList<T>(props: DraggableFlatListProps<T>) {
7176 </ Animated . View >
7277 ) ;
7378}
79+
80+ // Generic forwarded ref type assertion taken from:
81+ // https://fettblog.eu/typescript-react-generic-forward-refs/#option-1%3A-type-assertion
82+ export const NestableDraggableFlatList = React . forwardRef (
83+ NestableDraggableFlatListInner
84+ ) as < T > (
85+ props : DraggableFlatListProps < T > & { ref ?: React . ForwardedRef < FlatList < T > > }
86+ ) => ReturnType < typeof NestableDraggableFlatListInner > ;
You can’t perform that action at this time.
0 commit comments