diff --git a/packages/react-query/src/__tests__/useQuery.test.tsx b/packages/react-query/src/__tests__/useQuery.test.tsx index 1ea5408ff6..a52b3d7cbc 100644 --- a/packages/react-query/src/__tests__/useQuery.test.tsx +++ b/packages/react-query/src/__tests__/useQuery.test.tsx @@ -4799,8 +4799,15 @@ describe('useQuery', () => { expect(count).toBe(2) - - expect(arrayPick(states, ['data', 'isStale', 'isFetching', 'isPending', 'isSuccess'])).toMatchInlineSnapshot(` + expect( + arrayPick(states, [ + 'data', + 'isStale', + 'isFetching', + 'isPending', + 'isSuccess', + ]), + ).toMatchInlineSnapshot(` [ { "data": undefined, diff --git a/packages/react-query/src/__tests__/useSuspenseQuery.test.tsx b/packages/react-query/src/__tests__/useSuspenseQuery.test.tsx index 9d10fa5d02..13d1184a0d 100644 --- a/packages/react-query/src/__tests__/useSuspenseQuery.test.tsx +++ b/packages/react-query/src/__tests__/useSuspenseQuery.test.tsx @@ -903,4 +903,4 @@ describe('useSuspenseQuery', () => { ) consoleErrorSpy.mockRestore() }) -}) \ No newline at end of file +}) diff --git a/packages/react-query/src/useBaseQuery.ts b/packages/react-query/src/useBaseQuery.ts index bcad81e34d..37e1977924 100644 --- a/packages/react-query/src/useBaseQuery.ts +++ b/packages/react-query/src/useBaseQuery.ts @@ -84,8 +84,7 @@ export function useBaseQuery< const [_, setForceUpdate] = React.useState(0) - const result = - observer.getOptimisticResult(defaultedOptions) + const result = observer.getOptimisticResult(defaultedOptions) // console.log('result', result) React.useEffect(() => { @@ -96,7 +95,7 @@ export function useBaseQuery< const unsubscribe = observer.subscribe( notifyManager.batchCalls(() => { - setForceUpdate(n => n + 1) + setForceUpdate((n) => n + 1) }), ) @@ -107,7 +106,6 @@ export function useBaseQuery< return unsubscribe }, [observer, isRestoring]) - React.useEffect(() => { // Do not notify on updates because of changes in the options because // these changes should already be reflected in the optimistic result.