Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.0-dev7: useFirestoreDocumentData does not update invalidated data (react 18.2.0, react-query 3.39.2) #76

Open
alex-kowalczyk opened this issue Nov 1, 2022 · 1 comment

Comments

@alex-kowalczyk
Copy link

alex-kowalczyk commented Nov 1, 2022

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
  • onSuccess is 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 ref is called with proper "new" value

Until this point, works as expected. But the values are not updated in:

  • query data in react-query-devtools,
  • useFirestoreDocumentData hook data in React Dev Tools,
  • the app.
@HugoGresse
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants