rtk-query stars counter points to an archived repo.
Query now lives in the main repo as a package.
I understand that this isn't totally right, but at least it seems reasonable not to count start of an archived repo.
* docs(mutations): describe difference between using callbacks in useMutation and .mutate
* Text corrections
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* add subheader
* update consecutive mutations case to better describe ordering of mutation calls and fulfillment
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* docs(setQueriesData): Make setQueriesData more searchable
- Makes setQueriesData more searchable
- Change mention of fuzzily matching to partial matching since fuzzy matching is more arbitrary algorithm
- Mention setQueriesData in setQueryData to avoid confusion of behaviours
The purpose of this change is to make setQueriesData a bit more searchable from the docs to avoid confusion like this: https://github.com/tannerlinsley/react-query/discussions/3239
* Apply suggestions from code review
Co-authored-by: Ville Saukkonen <villesau@users.noreply.github.com>
Co-authored-by: Dominik Dorfmeister <office@dorfmeister.cc>
* fix(types): handle useQueries wrappers with strongly-typed array parameters
* test(types): confirm typecheck passes without explicit type for mapped query
* test(types): add typecheck on queryFn in mapped query
* refactor(useQueries) export QueriesOptions type
export the QueriesOptions type
closes#3250
* refactor(useQueries): add export to index
Add the export of the QueriesOptions type to the index file
* refactor(useQueries) export QueriesResults type
Export QueriesResults type
Co-authored-by: Jeffrey Sims <jeffreysims@Jeffrey-Sims-Mac.local>
On the first rendering, `hasNextPage` is `undefined`, but converted to `true` by the default value.
For intersection observer to trigger correctly without clicking more button, `hasNextPage` needs type casting.
incrementing and decrementing transactions need to happen in an atomic operation, no matter what happens in between; if we increment, but never decrement, we will get to a state where transactions can never become zero - we're basically "leaking" an open transaction. This leads to no observers being informed ever again because we think we still have an open transaction
this can be fixed by using try/finally to always decrement the transactions
* examples: react-native
Same example as in the Expo snack but in Typescript
* docs(examples): react-native: add link to the typescript version in the repo
* fix: use proper type for onAppStateChange
not all runs to createResult are saved on `this.currentResult` (optimistically created updates do not - we just create the result again later). With the fix from #3098, we made sure that memoized select does not run again in those cases by storing every run. However, that now means that we cannot rely on `prevResult.data` because it might still contain outdated data.
The solution is to store a pair of previous selectFn + data and return the exact data that was computed from the previous select fn if we get the exact same function passed
we compute the result optimistically, and then one more time when calling setOptions. Both times run the select function because only setOptions will update the previous result and previous options. storing the "previous" selectFn separately on the observer whenever it was invoked (independent of the fact from where it was called) side-steps the issue
* fix(useInfiniteQuery): fix infinite re-renders when select produced a new result
by correctly forwarding notifyOptions
* fix(useInfiniteQuery): fix suspense test
asserting the length of 3 seems wrong here and was likely only necessary because we triggered one too many re-renders before this fix :)
* fix(queriesObserver): fix getOptimisticResult call
Fix queriesObserver to call getOptimisticResult as before.
This was a bug introduced in PR #2866
* fix(queriesObserver): return observers in same order as queries
Sort returned observer entries to match the order of queries.
Previously, with keepPreviousData: true, the repurposed observers
would be returned last, potentially in different order than the queries.
* docs: add React Native code examples for common use cases
- Online status management
- Refetch on App focus
- Refresh on Screen focus
* docs(react-native): use useOnlineManager example
* fix(useQuery): continue retries if observer unmount and remount
if we are waiting for a retry to happen, unsubscribing he last observer will cancel retries and just return the error; however, if a new observer subscribes in the meantime, we should continue with the ongoing retries.
this is especially important with "strict effects" in react18, where effects are run twice and thus observers are always unsubscribed and re-subscribed immediately.
* fix(useQuery): continue retries if observer unmount and remount
add another test to include query cancellation