-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose
refresh
from infinite query hooks, and add RN FlatList examp…
…le (#4798) * Bump infinite query RTKQ build * Add rn-web and force infinite query example lockfile * Bump MSW worker * Add rn-web types * Expose refetch from infinite query hooks * Add RN FlatList example * Update root lockfile
- Loading branch information
1 parent
26bae54
commit db14ff5
Showing
11 changed files
with
9,400 additions
and
150 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
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
2 changes: 1 addition & 1 deletion
2
examples/query/react/infinite-queries/src/features/infinite-scroll/infiniteScrollApi.ts
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { baseApi } from "../baseApi" | ||
|
||
type Project = { | ||
export type Project = { | ||
id: number | ||
name: string | ||
} | ||
|
50 changes: 50 additions & 0 deletions
50
examples/query/react/infinite-queries/src/features/rn-flatlist/FlatlistExample.tsx
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,50 @@ | ||
import { ActivityIndicator, FlatList, View, Text } from "react-native-web" | ||
import { useMemo } from "react" | ||
|
||
import { apiWithInfiniteScroll } from "../infinite-scroll/infiniteScrollApi" | ||
import { ProjectRow } from "../infinite-scroll/InfiniteScrollExample" | ||
|
||
export const FlatlistExample = () => { | ||
const { | ||
data, | ||
error, | ||
fetchNextPage, | ||
fetchPreviousPage, | ||
hasNextPage, | ||
isFetchingNextPage, | ||
isLoading, | ||
isFetching, | ||
isError, | ||
// refetch, | ||
} = | ||
apiWithInfiniteScroll.endpoints.getProjectsCursor.useInfiniteQuery( | ||
"projects", | ||
) | ||
|
||
const allProjects = useMemo(() => { | ||
return data?.pages.flatMap(page => page.projects) ?? [] | ||
}, [data]) | ||
|
||
return ( | ||
<> | ||
<h2>React Native FlatList Example</h2> | ||
<View style={{ width: "100%", maxHeight: "600px" }}> | ||
{isLoading ? ( | ||
<ActivityIndicator /> | ||
) : isError ? ( | ||
<Text>{error?.message}</Text> | ||
) : ( | ||
<FlatList | ||
data={allProjects} | ||
keyExtractor={item => item.id.toString()} | ||
renderItem={({ item }) => <ProjectRow project={item} />} | ||
// onRefresh={refetch} | ||
refreshing={isLoading} | ||
progressViewOffset={100} | ||
onEndReached={() => fetchNextPage()} | ||
/> | ||
)} | ||
</View> | ||
</> | ||
) | ||
} |
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
Oops, something went wrong.