react-query-firebase
react-query-firebase copied to clipboard
1.0.0-dev7: useFirestoreDocumentData does not update invalidated data (react 18.2.0, react-query 3.39.2)
After bumping @react-query-firebase/firestore (mostly to workaround React 18.2.0 peer dep), the query invalidation stops working.
I do not have time to create minimal repro sandbox. Posting as a heads-up to others.
Reverting to 0.4.2 fixes the issue.
Simplified pseudo-code:
// Disable auto-refetching to avoid noise.
const queryClient = new QueryClient({defaultOptions: {queries: {staleTime: Infinity, cacheTime: Infinity}}});
<QueryClientProvider client={queryClient}>...</...>
const ref = docRef.withConverter(converter);
// simplified, just to demonstrate invalidation method.
const onSuccess = async () => ({await queryClient.invalidateQueries({predicate: () => true})});
const {data} = useFirestoreDocumentData(path, ref), // not a subscription
{mutate} = useFirestoreDocumentMutation(docRef, {merge: true}, {onSuccess});
Actual results when calling mutate({field: someVal})
- The value is updated is Firebase
onSuccessis called- The query is invalidated as expected and refetched, according to network/logs/react-query-devtools
- According to debug logs, after refetching the converter applied on
refis called with proper "new" value
Until this point, works as expected. But the values are not updated in:
- query data in react-query-devtools,
useFirestoreDocumentDatahook data in React Dev Tools,- the app.
Having the same issue, let us know if you need some repro, but basically:
- everything default,
- useFirestoreDocumentData(someRef)
- mutate,
- invalidate query in onSuccess
- useFirestoreDocumentData re-triggered but same value returned, confirmed using React Query dev tools, just the time and query count changed
I also tried some random sleep(1s) or more but it did not have any effect. Firestore persistence/offline not enable (web).