This document provides instructions for upgrading between major
versions of @lifeomic/one-query
-
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 sinceone-query
is mostly a typed wrapper aroundreact-query
most, if not all, things mentioned apply -
The
loading
status has been renamed topending
, and similarly the derivedisLoading
flag has been renamed toisPending
- query.status === 'loading'
+ query.status === 'pending'
- if (query.isLoading)
+ if (query.isPending)
useInfiniteAPIQuery
now requiresinitialPageParam
andgetNextPageParam
options. Passing page param throughfetchNextPage
andfetchPreviousPage
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 ofunknown
-
Callbacks on
useQuery
have been removed (e.g.,onSuccess
,onError
andonSettled
) -
Removed
keepPreviousData
in favor ofplaceholderData
identity function -
Rename
cacheTime
togcTime
-
Removed
refetchPage
in favor ofmaxPages
-
The experimental
suspense: boolean
flag on the query hooks has been removed - new hooks for suspense have been added