File tree Expand file tree Collapse file tree 6 files changed +34
-10
lines changed
packages/core/src/components Expand file tree Collapse file tree 6 files changed +34
-10
lines changed Original file line number Diff line number Diff line change 1+ import React from "react" ;
2+ import { FlatList as FlatListstComponent } from "react-native" ;
3+ import type { FlatListProps } from "react-native" ;
4+
5+ const FlatList = React . forwardRef < FlatListstComponent , FlatListProps < any > > (
6+ < T extends any > (
7+ { numColumns, ...rest } : FlatListProps < T > ,
8+ ref : React . Ref < FlatListstComponent >
9+ ) => {
10+ return (
11+ < FlatListstComponent
12+ key = { numColumns } // Changing numColumns requires re-rendering, setting it as the key ensures list is re-rendered when it changes
13+ numColumns = { numColumns }
14+ ref = { ref }
15+ { ...rest }
16+ />
17+ ) ;
18+ }
19+ ) ;
20+
21+ export default FlatList ;
Original file line number Diff line number Diff line change 11import React from "react" ;
22import { FlashListProps , FlashList } from "@shopify/flash-list" ;
3- import { FlatListProps , FlatList } from "react-native" ;
3+ import { FlatListProps , FlatList as FlatListComponent } from "react-native" ;
44import SectionHeader , { DefaultSectionHeader } from "./SectionHeader" ;
55import { flattenReactFragments } from "../../utilities" ;
6+ import FlatList from "../FlatList" ;
67
78type ListComponentType = "FlatList" | "FlashList" ;
89
@@ -52,7 +53,7 @@ const SectionList = React.forwardRef(
5253 keyExtractor : keyExtractorProp ,
5354 ...rest
5455 } : FlatListSectionListProps < T > | FlashListSectionListProps < T > ,
55- ref : React . Ref < FlatList | FlashList < any > >
56+ ref : React . Ref < FlatListComponent | FlashList < any > >
5657 ) => {
5758 const data = React . useMemo (
5859 ( ) => ( Array . isArray ( dataProp ) ? dataProp : [ ] ) as T [ ] ,
@@ -189,7 +190,7 @@ const SectionList = React.forwardRef(
189190 case "FlatList" :
190191 return (
191192 < FlatList
192- ref = { ref as React . Ref < FlatList > }
193+ ref = { ref as React . Ref < FlatListComponent > }
193194 stickyHeaderIndices = { sectionHeaderIndicies }
194195 { ...( rest as FlatListProps < SectionListItem < T > > ) }
195196 data = { dataWithSections }
Original file line number Diff line number Diff line change 11import React from "react" ;
2- import { FlatList } from "react-native" ;
2+ import FlatList from "../FlatList" ;
3+ import { FlatList as FlatListComponent } from "react-native" ;
34import type { FlatListProps } from "react-native" ;
45import useSplitContentContainerStyles from "./useSplitContentContainerStyles" ;
56
@@ -14,7 +15,7 @@ const SimpleStyleFlatList = React.forwardRef(
1415 data,
1516 ...rest
1617 } : Omit < FlatListProps < T > , "contentContainerStyle" > ,
17- ref : React . Ref < FlatList >
18+ ref : React . Ref < FlatListComponent >
1819 ) => {
1920 const { style, contentContainerStyle } =
2021 useSplitContentContainerStyles ( styleProp ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type {
55 FlashListSectionListProps ,
66} from "../SectionList" ;
77import useSplitContentContainerStyles from "./useSplitContentContainerStyles" ;
8- import { FlatList } from "react-native-gesture-handler " ;
8+ import { FlatList } from "react-native" ;
99import { FlashList } from "@shopify/flash-list" ;
1010
1111/**
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import type {
55 FlatListSwipeableListProps ,
66} from "../SwipeableItem" ;
77import useSplitContentContainerStyles from "./useSplitContentContainerStyles" ;
8- import { FlatList } from "react-native-gesture-handler " ;
8+ import { FlatList } from "react-native" ;
99import { FlashList } from "@shopify/flash-list" ;
1010
1111/**
Original file line number Diff line number Diff line change 11import React from "react" ;
22import { FlashListProps , FlashList } from "@shopify/flash-list" ;
3- import { FlatListProps , FlatList } from "react-native" ;
3+ import { FlatListProps , FlatList as FlatListComponent } from "react-native" ;
4+ import FlatList from "../FlatList" ;
45
56type ListComponentType = "FlatList" | "FlashList" ;
67
@@ -33,7 +34,7 @@ const SwipeableList = React.forwardRef(
3334 listComponent = "FlatList" ,
3435 ...rest
3536 } : FlashListSwipeableListProps < T > | FlatListSwipeableListProps < T > ,
36- ref : React . Ref < FlatList | FlashList < any > >
37+ ref : React . Ref < FlatListComponent | FlashList < any > >
3738 ) => {
3839 const [ isSwiping , setIsSwiping ] = React . useState ( false ) ;
3940
@@ -52,7 +53,7 @@ const SwipeableList = React.forwardRef(
5253 case "FlatList" :
5354 return (
5455 < FlatList
55- ref = { ref as React . Ref < FlatList > }
56+ ref = { ref as React . Ref < FlatListComponent > }
5657 { ...( rest as FlatListProps < T > ) }
5758 />
5859 ) ;
You can’t perform that action at this time.
0 commit comments