License
TanStack/query
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main
Could not load branches
Nothing to show
Could not load tags
Nothing to show
{{ refName }}
default
Code
-
Clone
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
- Open with GitHub Desktop
- Download ZIP
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Files
Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
v4 release (#3842<a data-pjax="true" title="v4 release (#3842)
* v4 alpha (#3060)
* feat(hydration): remove hydration package (#2936)
* V4: streamline cancel refetch (#2937)
* feat: streamline cancelRefetch
the following functions now default to true for cancelRefetch:
- refetchQueries (+invalidateQueries, + resetQueries)
- query.refetch
- fetchNextPage (unchanged)
- fetchPreviousPage (unchanged)
* feat: streamline cancelRefetch
make sure that refetchOnReconnect and refetchOnWindowFocus do not cancel already running requests
* feat: streamline cancelRefetch
update tests
refetch and invalidate now both cancel previous queries, which is intended, so we get more calls to the queryFn in these cases
* feat: streamline cancelRefetch
add more tests for cancelRefetch behavior
* feat: streamline cancelRefetch
update docs and migration guide
* feat: streamline cancelRefetch
simplify conditions by moving the ?? true default down to fetch on observer level; all 3 callers (fetchNextPage, fetchPreviousPage and refetch) just pass their options down and adhere to this default; refetch also only has 3 callers:
- refetch from useQuery, where we want the default
- onOnline and onFocus, where we now explicitly pass false to keep the previous behavior
and add more tests
* feat: streamline cancelRefetch
we always call this.fetch() with options, so we can just as well make the mandatory
also, streamline signatures by destructing values that can't be forwarded (and use empty object as default value) in options and just spread the rest
* feat: streamline cancelRefetch
fix types for refetch
it was accidentally made too wide and allowed all refetchFilters, like `predicate`; but with `refetch` on an obserserver, there is nothing to filter for, except the page, so that is what we need to accept via `RefetchPageFilters`
* feat: streamline cancelRefetch
refetch never took a queryKey as param - it is always bound to the observer
* feat: better query filters (#2938)
* fix: rename react directory to reactjs (#2884)
* fix: rename react directory to reactjs
the directory being named "react" causes an error with the moduleDirectories option from jest
* fix: update package.json files to match the updated reactjs directory name
* fix: change react test utils imports to match new directory name
* docs(v4): add renamed reactjs details to migration guide
Co-authored-by: Eddy Vinck <eddy.vinck@isaac.nl>
* feat: mutation cache duration (#2963)
* feat: mutation cachetime
stramline queryCache / mutationCache events by combining them into notifiable.ts
* feat: mutation cachetime
removable
* feat: mutation cachetime
add gc to mutations
* feat: mutation cachetime
streamline event types between queries and mutations
* feat: mutation cachetime
tests, and I forgot to implement optionalRemove, so make it abstract
* feat: mutation cachetime
replicate gc behavior from https://github.com/tannerlinsley/react-query/pull/2950 and add more tests
* feat: mutation cachetime
get test coverage back to 100%
* feat: mutation cachetime
docs
* feat: mutation cachetime
try to make tests more resilient
* feat: mutation cachetime
fix imports after merge conflict
* refactor(persistQueryClient): Make persistQueryClient stable (#2961)
* :truck: Remove experimental from persist-query-client
* :truck: Rename persistor -> persister
* ✏️ Fix Persistor -> Persister in imports
* :truck: Update name in rollup config
* :truck: Move createAsyncStoragePersister and createWebStoragePersister to stable version and rename persistor -> persister
* 📝 Update documentation
* 📝 Add migrating to v4 docs
* Apply suggestions from code review
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* 2964 changes to on success callback (#2969)
* feat(useQuery): onSuccess callback
do not call onSuccess if update was done manually from setQueryData
* feat(useQuery): onSuccess callback
test that onSuccess is not called when setQueryData is used
* feat(useQuery): onSuccess callback
docs changes
* feat(useQuery): onSuccess callback
options spread is wrong - `updatedAt` is actually `dataUpdatedAt`. Oddly we didn't have a test, so I added one
* 2919 query key array (#2988)
* feat: query key array
remove code that internally ensures that we get an Array, because it is now the expected interface, ensured by TypeScript
* feat: query key array
update tests to the new syntax
* feat: query key array
fix assertions, because there is no array wrapping happening internally anymore. The key you receive from the context is exactly the key you passed in
* feat: query key array
this test doesn't make much sense anymore
* feat: query key array
wrapping in an extra array doesn't yield the same results anymore since v4 because keys need to be an array
* feat: query key array
make docs adhere to new array key syntax
* feat: query key array
migration docs
* feat(QueryObserver): track queries as default (#2987)
* feat(Query Options): remove notifyOnChangePropsExclusion
- remove related code from queryObserver
- remove type def
- remove related tests
* docs(Query Options): update notifyOnChangePropsExclusion sections
- remove from api references
- add to v4 migration guide
* feat(QueryObserver): "tracked" as default behavior
- remove "tracked" completely if notifyOnChangeProps is not defined, behave as v3 "tracked"
- add `notifyOnChangeProps: 'all' to opt out of the smart tracking
TODO: Now that default behavior has changed, work out the failed tests. Which parts to change for current ones and possibly write new ones.
* test(useQuery): adjust tests to pass for notifyOnChangeProps udpate
* test(useInfiniteQuery): adjust tests to pass for notifyOnChangeProps udpate
* test(QueryResetErrorBoundary): adjust tests to pass for notifyOnChangeProps udpate
* refactor(QueryObserver): use nullish coalescing operator
much cleaner than the negated if I started with
* test(QueryResetErrorBoundary): remove "tracked" from test
* revert: test(QueryResetErrorBoundary): adjust tests to pass for notifyOnChaneProps udpate
This reverts commit a34b4720675dad5ee6ebde401639f328c0c83122.
The changes are not necessary after PR #2993 fix.
* refactor(QueryObserver): combine prop checks
* docs(notifyOnChangeProps): update docs to reflect new api
* refactor: Remove deprecated promise cancel (#2996)
* :fire: Remove the cancel method on promise for cancelling promise
* ✅ Fix query client tests
* ✅ Update query and useQuery tests
* ✅ Update use infinite query tests
* 📝 Update migartion guide
* :bug: Fix linking in documentation
* :pencil: Fix grammatical errors in docs
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* :refactor: Use abortSignal for query cancellation in InfiniteQueryBehavior
* 🚨 Fix lint errors
* :recycle: Move define signal property to a separate function
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* remove test that doesn't make sense anymore - we don't allow different falsy query keys now
* 2927 offline queries (#3006)
* feat(useQuery): offline queries
remove defaultQueryObserverOptions because it is the same as defaultQueryOptions and we can just use that
* feat(useQuery): offline queries
setup dependent default values, to make it easier to work with them
* feat(useQuery): offline queries
basic changes to retryer:
- pause the query before fetching depending upon networkMode
- pause retries depending upon networkRetry
* feat(useQuery): offline queries
move networkRetry and networkMode defaults to the retryer creation, because we need the same for mutations
* feat(useQuery): offline queries
decouple focus and online manager: we're now informing caches of a focus when we're focussed, and about an online event if we come online; if the retryer continues, it can then decide to not fetch depending on our networkMode
* feat(useQuery): offline queries
expose isPaused on the queryResult and make sure isFetching is false when we are paused
* feat(useQuery): offline queries
knowing if we can fetch depends on if we are paused or not, as other conditions should apply
also, rename options (not sure if that will stick though)
* feat(useQuery): offline queries
adjust existing tests for isPaused being exposed
* feat(useQuery): offline queries
fix existing test by setting options to emulate the previous behaviour, otherwise, with `mockNavigatorOnline` being set to false right from the start, the mutation would never fire off
* feat(useQuery): offline queries
adapt onOnline, onFocus tests to new behavior: they are now decoupled, and onOnline is always called even when not focused and vice versa. The retryer should make sure to not continue fetching if necessary
* feat(useQuery): offline queries
first test for networkMode
* feat(useQuery): offline queries
isFetching and isPaused are now derived and stored together in a fetchingState enum (idle, fetching, paused)
* feat(useQuery): offline queries
better networkMode api: online, always, offlineFirst (basically always but with paused retries)
* feat(useQuery): offline queries
more tests for networkMode: online
* feat(useQuery): offline queries
more tests for networkMode: online
* feat(useQuery): offline queries
tests for networkMode: always
* feat(useQuery): offline queries
fix tests that were influencing each other by using proper jest mocks for online and visibility state
* add paused queries to the devtools.tsx
* feat(useQuery): offline queries
never stop pausing when continueFn is called. Initially, I only had this guard for when it's called from the outside, e.g. for onWindowFocus while still being offline, but we need this always because otherwise query cancellation can potentially continue a paused query
* feat(useQuery): offline queries
okay, pausing multiple times was a bad idea, continueFn() will be called eventually anyways
* feat(useQuery): offline queries
attempt at offline toggle button
* feat(useQuery): offline queries
different icons, padding, color
* feat(useQuery): offline queries
i messed up the icon order
* feat(useQuery): offline queries
guard against illegal state transitions: paused queries can unmount or get cancelled, in which case we shouldn't continue them, even if we dispatch the continue event
* feat(useQuery): offline queries
fix devtools tests, account for paused queries
* Revert "feat(useQuery): offline queries"
This reverts commit a647f64a051ca4c02a872e7871b4b2ce49aeda2c.
* feat(useQuery): offline queries
keep the do-not-start logic out of the run function, and thus out of promiseOrValue. if the promise has already been resolved in the meantime, e.g. because of a `cancel`, the run method will just do nothing, while the previous logic would've started to fetch
* feat(useQuery): offline queries
show inactive as higher priority than paused
* feat(useQuery): offline queries
make sure that optimistic results don't show an intermediate fetching state, but go opmistically to paused instead
* feat(useQuery): offline queries
real result needs to match optimistic result
* feat(useQuery): offline queries
stupid mistake
* feat(useQuery): offline queries
keep status color and status label in sync
* feat(useQuery): offline queries
make networkMode param mandatory for canFetch (and default to online internally) so that we can't screw that up again
* feat(useQuery): offline queries
make sure test "finishes" to avoid prints to the console if another test goes online again
* feat(useQuery): offline queries
move cancel function to the top, as it's no longer dependent on the promise since the