@tanstack/react-query 4.10.1 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query",
3
- "version": "4.10.1",
3
+ "version": "4.12.0",
4
4
  "description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -35,12 +35,18 @@
35
35
  ],
36
36
  "devDependencies": {
37
37
  "@types/jscodeshift": "^0.11.3",
38
+ "@types/react": "^18.0.14",
39
+ "@types/react-dom": "^18.0.5",
38
40
  "@types/use-sync-external-store": "^0.0.3",
41
+ "react": "^18.2.0",
42
+ "react-17": "npm:react@^17.0.2",
43
+ "react-dom": "^18.2.0",
44
+ "react-dom-17": "npm:react-dom@^17.0.2",
39
45
  "jscodeshift": "^0.13.1",
40
46
  "react-error-boundary": "^3.1.4"
41
47
  },
42
48
  "dependencies": {
43
- "@tanstack/query-core": "4.10.1",
49
+ "@tanstack/query-core": "4.12.0",
44
50
  "use-sync-external-store": "^1.2.0"
45
51
  },
46
52
  "peerDependencies": {
@@ -60,7 +66,7 @@
60
66
  "clean": "rm -rf ./build",
61
67
  "test:codemods": "../../node_modules/.bin/jest --config codemods/jest.config.js",
62
68
  "test:eslint": "../../node_modules/.bin/eslint --ext .ts,.tsx ./src",
63
- "test:jest": "pnpm test:codemods && ../../node_modules/.bin/jest --config jest.config.js",
64
- "test:jest:dev": "pnpm test:jest --watch"
69
+ "test:jest": "pnpm run test:codemods && ../../node_modules/.bin/jest --config ./jest.config.ts",
70
+ "test:dev": "pnpm run test:jest --watch"
65
71
  }
66
72
  }
@@ -2269,40 +2269,6 @@ describe('useQuery', () => {
2269
2269
  expect(queryCache.find(key)!.options.queryFn).toBe(queryFn1)
2270
2270
  })
2271
2271
 
2272
- it('should render correct states even in case of useEffect triggering delays', async () => {
2273
- const key = queryKey()
2274
- const states: UseQueryResult<string>[] = []
2275
-
2276
- const originalUseEffect = React.useEffect
2277
-
2278
- // Try to simulate useEffect timing delay
2279
- // @ts-ignore
2280
- React.useEffect = (...args: any[]) => {
2281
- originalUseEffect(() => {
2282
- setTimeout(() => {
2283
- args[0]()
2284
- }, 10)
2285
- }, args[1])
2286
- }
2287
-
2288
- function Page() {
2289
- const state = useQuery(key, () => 'data', { staleTime: Infinity })
2290
- states.push(state)
2291
- return null
2292
- }
2293
-
2294
- renderWithClient(queryClient, <Page />)
2295
- queryClient.setQueryData(key, 'data')
2296
- await sleep(50)
2297
-
2298
- // @ts-ignore
2299
- React.useEffect = originalUseEffect
2300
-
2301
- expect(states.length).toBe(2)
2302
- expect(states[0]).toMatchObject({ status: 'loading' })
2303
- expect(states[1]).toMatchObject({ status: 'success' })
2304
- })
2305
-
2306
2272
  it('should batch re-renders', async () => {
2307
2273
  const key = queryKey()
2308
2274
 
@@ -109,11 +109,13 @@ export function executeMutation(
109
109
  // so that we can pretend to be in a server environment
110
110
  export function setIsServer(isServer: boolean) {
111
111
  const original = utils.isServer
112
- // @ts-ignore
113
- utils.isServer = isServer
112
+ Object.defineProperty(utils, 'isServer', {
113
+ get: () => isServer,
114
+ })
114
115
 
115
116
  return () => {
116
- // @ts-ignore
117
- utils.isServer = original
117
+ Object.defineProperty(utils, 'isServer', {
118
+ get: () => original,
119
+ })
118
120
  }
119
121
  }