From 9c93dc0642be0df4497e02cd537300ecb7b45f81 Mon Sep 17 00:00:00 2001 From: Kae Date: Sun, 3 Nov 2024 23:14:15 +0900 Subject: [PATCH] fix(query-devtools): handle null properties for __previousQueryOptions (#8240) Co-authored-by: Dominik Dorfmeister --- packages/query-devtools/src/Devtools.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/query-devtools/src/Devtools.tsx b/packages/query-devtools/src/Devtools.tsx index 4db77d7737..aac57a55b4 100644 --- a/packages/query-devtools/src/Devtools.tsx +++ b/packages/query-devtools/src/Devtools.tsx @@ -1789,15 +1789,20 @@ const QueryDetails = () => { const restoreQueryAfterLoadingOrError = () => { const activeQueryVal = activeQuery()! const previousState = activeQueryVal.state - const previousOptions = (activeQueryVal.state.fetchMeta as any) - .__previousQueryOptions + const previousOptions = activeQueryVal.state.fetchMeta + ? (activeQueryVal.state.fetchMeta as any).__previousQueryOptions + : null + activeQueryVal.cancel({ silent: true }) activeQueryVal.setState({ ...previousState, fetchStatus: 'idle', fetchMeta: null, }) - activeQueryVal.fetch(previousOptions) + + if (previousOptions) { + activeQueryVal.fetch(previousOptions) + } } createEffect(() => {