From ff4e8a459f22fc2477fd732e95cc01e625e0b0c0 Mon Sep 17 00:00:00 2001 From: Kae Date: Sun, 3 Nov 2024 21:18:43 +0900 Subject: [PATCH] fix: handle null properties for __previousQueryOptions --- 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(() => {