Skip to content

Latest commit

 

History

History
56 lines (41 loc) · 1.84 KB

UPGRADING.md

File metadata and controls

56 lines (41 loc) · 1.84 KB

This document provides instructions for upgrading between major versions of @lifeomic/one-query

3.x -> 4.x

  • Replace your installation of @tanstack/react-query@4.x with @tanstack/react-query@5.x

  • See react-query's migration guide for an idea. The largest changes will be outlined below - however since one-query is mostly a typed wrapper around react-query most, if not all, things mentioned apply

  • The loading status has been renamed to pending, and similarly the derived isLoading flag has been renamed to isPending

- query.status === 'loading'
+ query.status === 'pending'

- if (query.isLoading)
+ if (query.isPending)
  • useInfiniteAPIQuery now requires initialPageParam and getNextPageParam options. Passing page param through fetchNextPage and fetchPreviousPage is no longer supported.
-  const query = useInfiniteAPIQuery('GET /list', {
-   filter: 'some-filter',
-   after: undefined,
- });
- await void query.fetchNextPage({ pageParam: {...} });
+ const query = useInfiniteAPIQuery(
+   'GET /list',
+   {
+     filter: 'some-filter',
+     after: undefined,
+   },
+   {
+     initialPageParam: {},
+     getNextPageParam: (lastPage) => ({
+       after: lastPage.next,
+     }),
+   },
+ );
+ await void query.fetchNextPage();
  • The minimum required TypeScript version is now 4.7

  • TypeScript: Error is now the default type for errors instead of unknown

  • Callbacks on useQuery have been removed (e.g., onSuccess, onError and onSettled)

  • Removed keepPreviousData in favor of placeholderData identity function

  • Rename cacheTime to gcTime

  • Removed refetchPage in favor of maxPages

  • The experimental suspense: boolean flag on the query hooks has been removed - new hooks for suspense have been added