Skip to content

Commit

Permalink
Change to using Flatlist from gesture-handler - 52 (#984)
Browse files Browse the repository at this point in the history
* update to using Flatlist from gesture-handler

* fix typescript
  • Loading branch information
sieu-db authored Jan 13, 2025
1 parent f8876b6 commit 07571fd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/core/src/components/FlatList.tsx
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from "react";
import { FlatList as FlatListstComponent } from "react-native";
import { FlatList as FlatListComponent } from "react-native-gesture-handler";
import type { FlatListProps } from "react-native";

const FlatList = React.forwardRef<FlatListstComponent, FlatListProps<any>>(
const FlatList = React.forwardRef<FlatListComponent, FlatListProps<any>>(
<T extends any>(
{ numColumns, ...rest }: FlatListProps<T>,
ref: React.Ref<FlatListstComponent>
ref: React.Ref<FlatListComponent>
) => {
return (
<FlatListstComponent
<FlatListComponent
key={numColumns} // Changing numColumns requires re-rendering, setting it as the key ensures list is re-rendered when it changes
numColumns={numColumns}
ref={ref}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/SectionList/SectionList.tsx
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { FlashListProps, FlashList } from "@shopify/flash-list";
import { FlatListProps, FlatList as FlatListComponent } from "react-native";
import { FlatListProps } from "react-native";
import { FlatList as FlatListComponent } from "react-native-gesture-handler";
import SectionHeader, { DefaultSectionHeader } from "./SectionHeader";
import { flattenReactFragments } from "../../utilities";
import FlatList from "../FlatList";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/SimpleStyleScrollables/SimpleStyleFlatList.tsx
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import FlatList from "../FlatList";
import { FlatList as FlatListComponent } from "react-native";
import { FlatList as FlatListComponent } from "react-native-gesture-handler";
import type { FlatListProps } from "react-native";
import useSplitContentContainerStyles from "./useSplitContentContainerStyles";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
FlashListSectionListProps,
} from "../SectionList";
import useSplitContentContainerStyles from "./useSplitContentContainerStyles";
import { FlatList } from "react-native";
import { FlatList as FlatListComponent } from "react-native-gesture-handler";
import { FlashList } from "@shopify/flash-list";

/**
Expand All @@ -22,7 +22,7 @@ const SimpleStyleSectionList = React.forwardRef(
FlatListSectionListProps<T> | FlashListSectionListProps<T>,
"contentContainerStyle"
>,
ref: React.Ref<FlatList | FlashList<any>>
ref: React.Ref<FlatListComponent | FlashList<any>>
) => {
const { style, contentContainerStyle } =
useSplitContentContainerStyles(styleProp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
FlatListSwipeableListProps,
} from "../SwipeableItem";
import useSplitContentContainerStyles from "./useSplitContentContainerStyles";
import { FlatList } from "react-native";
import { FlatList as FlatListComponent } from "react-native-gesture-handler";
import { FlashList } from "@shopify/flash-list";

/**
Expand All @@ -22,7 +22,7 @@ const SimpleStyleSwipeableList = React.forwardRef(
FlashListSwipeableListProps<T> | FlatListSwipeableListProps<T>,
"contentContainerStyle"
>,
ref: React.Ref<FlatList | FlashList<any>>
ref: React.Ref<FlatListComponent | FlashList<any>>
) => {
const { style, contentContainerStyle } =
useSplitContentContainerStyles(styleProp);
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/SwipeableItem/SwipeableList.tsx
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { FlashListProps, FlashList } from "@shopify/flash-list";
import { FlatListProps, FlatList as FlatListComponent } from "react-native";
import { FlatListProps } from "react-native";
import { FlatList as FlatListComponent } from "react-native-gesture-handler";
import FlatList from "../FlatList";

type ListComponentType = "FlatList" | "FlashList";
Expand Down

0 comments on commit 07571fd

Please sign in to comment.