0
Fork 0
mirror of https://github.com/TanStack/query.git synced 2026-11-16 22:50:20 +00:00
Commit graph

5,194 commits

Author SHA1 Message Date
Andrii Artemenko
9b5d18cd47
fix(devtools): add code element's background (#3287) v3.34.15
Prevent code element's backround from being overwritten
2022-02-12 20:15:33 +01:00
flash548
e3df8b1841
docs: Update useQuery.md (#3281)
was missing the placeholderData field on the `useQuery` options signature... but its listed in detail on the latter part of the page.
2022-02-12 18:49:02 +01:00
Tommy Tan
d8c46ce30a
docs: update testing.md (#3278)
fixes sentence by removing "our".
2022-02-08 22:43:35 +01:00
Ville Saukkonen
6d6d9d06cd
docs(setQueriesData): Make setQueriesData more searchable (#3244)
* 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>
2022-02-06 15:09:21 +01:00
Dominik Dorfmeister
b38eed6326 chore: fix prettier v3.34.14 2022-02-06 09:47:24 +01:00
Arty
a470f4601b
fix(types): useQueries to also handle array-params with typed QueryKey (#3267)
* 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
2022-02-06 09:33:59 +01:00
Arnaud
efb77d7c40
docs(cancellation): add graphql request v4 example (#3264) 2022-02-05 13:09:21 +01:00
Jeff Sims
a536773b00
fix(types): export QueriesOptions and QueriesResults types for useQueries (#3251) v3.34.13
* 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>
2022-02-05 08:34:37 +01:00
fediev
4dcb490d4d
docs(tests): infinite scroll without click more button (#3247)
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.
2022-01-30 14:58:28 +01:00
Amen SOUISSI
6710bc1715
fix(types): use MutationKey instead of QueryKey for useIsMutating (#3222) v3.34.12 2022-01-23 16:47:23 +01:00
Dominik Dorfmeister
c532d81313
fix(core): make sure batching finishes if exception is thrown (#3216) v3.34.11
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
2022-01-21 13:24:22 +01:00
Bennett Dams
f5a0ceceae
docs(ssr): Hydration caveat for Next.js' rewrites (#3209) v3.34.10
Adds a small section for a caveat about hydration when using some specific feature/configuration of Next.js
2022-01-21 13:19:42 +01:00
Arty
11f4ea99c0
fix(useQueries): allow types to work with strongly typed QueryFunction + QueryKey (#3214) 2022-01-21 13:18:28 +01:00
Damian Osipiuk
26b39546cc
fix(types): export QueryClientConfig interface (#3203) v3.34.9 2022-01-21 13:10:11 +01:00
Arnaud
e328ca0bc3
docs(examples): react-native: regenerate yarn.lock (#3197)
Regenerate a clean yarn.lock file without versions issues.
2022-01-16 09:16:17 +01:00
Arnaud
56e3ba7a9c
docs(examples): react-native: update .gitignore to exclude lib folder (#3196) 2022-01-14 14:06:50 +01:00
Arnaud
6722d06d22
docs(examples): react-native basic app in typescript (#3174)
* 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
2022-01-14 09:16:34 +01:00
Dominik Dorfmeister
755702dd78
fix(queryObserver): fix data stability (#3183) v3.34.8
by making sure to memoize the structurally shared version of data rather than the raw one
2022-01-12 14:53:10 +01:00
maricabertarini
d4c6798edf
docs(examples/load-more-infinite-scroll): fix wrong condition (#3175) 2022-01-11 20:40:53 +01:00
Scott Davis
02f681d6ae
docs(useMutation): clarify retry default value (#3159)
This makes the default value more apparent and adds `retry` and `retryDelay` to the example code.
2022-01-05 18:42:55 +01:00
allcontributors[bot]
98fbec5896
docs: add arnaudbzn as a contributor for code, doc (#3157)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2022-01-04 22:25:40 +01:00
Arnaud
d779df14e9
docs(examples): add react native expo snack example (#3156) 2022-01-04 22:15:51 +01:00
Dominik Dorfmeister
d12d0cf5bc
chore: issue template (#3154) 2022-01-02 12:44:19 +01:00
Dmitriy Fishman
f4eb19421c
docs: Fix a typo in tkdodos-blog.md (#3152) 2021-12-31 11:29:15 +01:00
DidrikLind
93824ec731
refactor(examples): use triple equal instead of double equal (#3135) 2021-12-28 22:12:04 +01:00
Dominik Dorfmeister
d7faf86005
fix(queryObserver): memoized select functions should not return outdated values (#3140) v3.34.7
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
2021-12-28 18:34:17 +01:00
Damian Osipiuk
b977cf4ddd
refactor(types): use core types in useMutation instead of redefining them (#3122) 2021-12-23 10:13:10 +01:00
Marco Pasqualetti
ca2a57aa4e
fix(devtools): code color is not inherited from panel color (#3115) v3.34.6 2021-12-23 10:07:53 +01:00
Dominik Dorfmeister
3981f5219a
fix(query): set error to null when going to loading state (#3106) v3.34.5
to be aligned with the types, as `loading` cannot have an `error` set.
2021-12-17 12:54:54 +01:00
Dominik Dorfmeister
2054f5b227
fix(queryObserver): make sure that memoized select function only runs once per input (#3098) v3.34.4
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
2021-12-15 19:52:32 +01:00
François Robichet
f9077bcb2c
docs: Add cacheTime default (#3094) 2021-12-14 20:05:53 +01:00
Dominik Dorfmeister
128e578c08
fix: unsubscribe correctly in onlineManager and focusManager (#3092) v3.34.3 2021-12-14 13:08:19 +01:00
Jbee
078114254d
fix(core): remove enabled condition in queryObserver for suspense (#3093)
* fix(core): remove enabled condition in queryObserver

https://github.com/tannerlinsley/react-query/issues/2434

* chore: add missing test case

* chore: fix format
2021-12-14 13:07:29 +01:00
Clifford Fajardo
988ba10a71
chore: update bug report template (#3089) 2021-12-13 07:16:57 +01:00
Dominik Dorfmeister
ca335dec7b
fix(useInfiniteQuery): fix infinite re-renders when select produced a new result (#3081) v3.34.2
* 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 :)
2021-12-10 13:47:00 +01:00
Hyeonsu Lee
0f00cda954
docs: Make react-native example up-to-date #3057 2021-12-10 13:14:30 +01:00
Clement Bowe
e4da8dd10b
docs: Update does-this-replace-client-state.md (#3070) v3.34.1
changed "any boilerplate code that use"  to boilerplate code that was used" to improve the clarity of the sentence.
2021-12-09 20:37:16 +01:00
allcontributors[bot]
ebf1e68a52
docs: add jvuoti as a contributor for code (#3053)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-12-04 22:57:25 +01:00
Janne Vuoti
2ec1979f9c
fix(queriesObserver): fix getOptimisticResult, order of returned observers (#3052)
* 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.
2021-12-04 22:56:37 +01:00
Arnaud
5fd537e4c2
docs(react-native): add code examples for common use cases (#3042)
* 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
2021-12-03 09:04:11 +01:00
stefanprobst
aec640a595
feat(mutation): add onMutate to MutationCache (#3038) v3.34.0 2021-12-01 06:55:41 +01:00
Dominik Dorfmeister
dc2df1066f
fix(useQuery): continue retries if query unmounts and remounts (#3032) v3.33.7
* 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
2021-11-28 08:17:22 +01:00
Janne Vuoti
c51498a935
fix(useQueries): search for unused observers if keepPreviousData (#2680) (#2866) v3.33.6 2021-11-26 21:06:00 +01:00
Alec Flett
c6906b3c4d
fix(useQueries): add useMemo to useQueries to keep result stable (#2992) v3.33.5 2021-11-24 20:07:44 +01:00
Timo Dörr
f18881d27b
docs: add pitfalls section for window focus refetching (#3018) 2021-11-24 08:48:24 +01:00
Tomer
911477422f
docs(query-keys guide): change "And" to "An" (#3010) 2021-11-23 12:03:21 +01:00
Dominik Dorfmeister
0aafb42fcc
fix(query): make sure prefetched queries can be garbage collected (#3007) v3.33.4 2021-11-22 17:40:11 +01:00
Dominik Dorfmeister
27e72de267
fix(useQuery): cleanup queries even if they have been fetching (#2950) v3.33.3
* fix(useQuery): cleanup queries even if they have been fetching

* fix(useQuery): cleanup queries even if they have been fetching

do not re-schedule garbage collection if a query is fetching and we never had any observers subscribed; this is necessary to make suspense work, because with suspense, we always throw before we subscribe, so the garbage collection would prematurely remove the query, resulting in an infinite loop

* fix(useQuery): cleanup queries even if they have been fetching

only schedule garbage collection when the last observer unsubscribes rather than in the constructor

this works around the suspense issue because we only add observers after we've loaded as we throw before that.
2021-11-22 14:45:21 +01:00
allcontributors[bot]
ebd22b203a
docs: add babycourageous as a contributor for code, doc (#2995)
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-11-20 17:42:36 +01:00
Dominik Dorfmeister
58dc1ce626
fix(useQuery): fix tracked queries and error boundaries (#2993) v3.33.2
if you useErrorBoundary, you're likely not observing the error, because you're not using the returned error field - the ErrorBoundary handles the error for you. So when the actual error then happens, we don't inform the observer about it, because we're only informing them if a prop has changed that they are interested in, resulting in the error boundary never being shown.

The solution would be to always track the error property if you've set useErrorBoundary
2021-11-20 08:57:36 +01:00