Skip to content

Commit 16c6dfb

Browse files
committed
v1.2.2
1 parent 66662a4 commit 16c6dfb

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 1.2.2
4+
5+
- Fixed an issue where garbage collection was messing with proper test cleanup
6+
- Fixed an issue where tests were giving false positives because of the above
7+
- Fixed an issue where query creation during the render phase was eventually triggering setState (found via a cache subscription in the `useIsFetching` hook, when used in the same parent component as a query)
8+
39
## 1.2.1
410

511
- Fixed an issue where the `throwOnError` option was not working for `queryCache.prefetchQuery`

media/logo.sketch

-636 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-query",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
55
"author": "tannerlinsley",
66
"license": "MIT",

src/queryCache.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ export function makeQueryCache() {
134134
if (query.queryHash) {
135135
if (!isServer) {
136136
cache.queries[queryHash] = query
137-
notifyGlobalListeners()
137+
// Here, we setTimeout so as to not trigger
138+
// any setState's in parent components in the
139+
// middle of the render phase.
140+
setTimeout(() => {
141+
notifyGlobalListeners()
142+
})
138143
}
139144
}
140145
}
@@ -243,7 +248,9 @@ export function makeQueryCache() {
243248
query.cacheTimeout = setTimeout(
244249
() => {
245250
cache.removeQueries(
246-
d => d.state.markedForGarbageCollection && d.queryHash === query.queryHash
251+
d =>
252+
d.state.markedForGarbageCollection &&
253+
d.queryHash === query.queryHash
247254
)
248255
},
249256
typeof query.state.data === 'undefined' &&

0 commit comments

Comments
 (0)