-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(boilerplate)
@shopify/flash-list
integration and ListView HOC (#…
…2513) * feat(boilerplate) @shopify/flash-list integration This integrates @shopify/flash-list in all places where we used to have a FlatList and updates the expo to compatibility object to use the correct expected version while using the latest for expo prebuild and bare workflows. * fix: ios compiling issue when the user specifies the new architecture * fix: Get FlashList working in new architecture using interop layer iOS seems to have problems with flashlist using interop, but android seems to work just fine. * feat: adds ListView Higher Order Component Displays a FlashList or FlatList depending on language RTL features. Needs a little more work on the `ref` passing. * chore: formatting * refactor(boilerplate): ListView HOC types * chore(tests) Tests passing after adding new ListView component * ci: bun version lock --------- Co-authored-by: Frank Calise <fcalise@gmail.com>
- Loading branch information
1 parent
bddaea5
commit 1ac2870
Showing
15 changed files
with
104 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React, { forwardRef, PropsWithoutRef } from "react" | ||
import { FlatList } from "react-native" | ||
import { isRTL } from "app/i18n" | ||
import { FlashList, FlashListProps } from "@shopify/flash-list" | ||
|
||
export type ListViewRef<T> = FlashList<T> | FlatList<T> | ||
|
||
export type ListViewProps<T> = PropsWithoutRef<FlashListProps<T>> | ||
|
||
/** | ||
* This is a Higher Order Component meant to ease the pain of using @shopify/flash-list | ||
* when there is a chance that a user would have their device language set to an | ||
* RTL language like Arabic or Punjabi. This component will use react-native's | ||
* FlatList if the user's language is RTL or FlashList if the user's language is LTR. | ||
* | ||
* Because FlashList's props are a superset of FlatList's, you must pass estimatedItemSize | ||
* to this component if you want to use it. | ||
* | ||
* This is a temporary workaround until the FlashList component supports RTL at | ||
* which point this component can be removed and we will default to using FlashList everywhere. | ||
* | ||
* @see {@link https://github.com/Shopify/flash-list/issues/544|RTL Bug Android} | ||
* @see {@link https://github.com/Shopify/flash-list/issues/840|Flashlist Not Support RTL} | ||
* | ||
* @param props - FlashListProps | FlatListProps | ||
* @param forwardRef - React.Ref<ListProps<T>> | ||
* @returns JSX.Element | ||
*/ | ||
|
||
const ListViewComponent = forwardRef( | ||
<T,>(props: ListViewProps<T>, ref: React.ForwardedRef<ListViewRef<T>>) => { | ||
const ListComponentWrapper = isRTL ? FlatList : FlashList | ||
|
||
return <ListComponentWrapper {...props} ref={ref} /> | ||
}, | ||
) | ||
|
||
ListViewComponent.displayName = "ListView" | ||
|
||
export const ListView = ListViewComponent as <T>( | ||
props: ListViewProps<T> & { | ||
ref?: React.RefObject<ListViewRef<T>> | ||
}, | ||
) => React.ReactElement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ListView Component | ||
|
||
The `ListView` component is a Higher Order Component that uses [Shopify's FlashList](https://shopify.github.io/flash-list/) component to display a list unless the user's preferred language is RTL (right-to-left). This is because FlashList has [known](https://github.com/Shopify/flash-list/issues/544) [issues](https://github.com/Shopify/flash-list/issues/840) with RTL support. Once these issues with FlashList are resolved, this component will be deprecated and FlashList will be used directly. | ||
|
||
## Props | ||
|
||
The `ListView` component uses props from `FlashList` because they are a superset of `FlatList` and only require one extra prop to work for both component types. | ||
|
||
> [Please see the FlashList documentation for more information on the props that are available.](https://shopify.github.io/flash-list/docs/usage) | ||
### `estimatedItemSize` | ||
|
||
> [Please see the FlashList documentation for more information on this prop.](https://shopify.github.io/flash-list/docs/estimated-item-size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters