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

reload() doesn't update existing items with useCollectionOnce #300

Open
ZakKa89 opened this issue Apr 19, 2023 · 2 comments
Open

reload() doesn't update existing items with useCollectionOnce #300

ZakKa89 opened this issue Apr 19, 2023 · 2 comments

Comments

@ZakKa89
Copy link

ZakKa89 commented Apr 19, 2023

I'm guessing this is more of a cache issue with firebase than the library. But I was wondering if somebody bumped into the same issue and has a solution.

The issue

if you update an item in a collection, and use the reload() function to refetch, the item will not not be updated. The refetch is only useful in adding or deleting items.

Possible workarounds

  • manually optimistically updating the state myself.
  • Turning on realtime data again, but my client doesn't want this.
@TaylorFoster-Informulate
Copy link

TaylorFoster-Informulate commented Sep 9, 2024

+1 on this. reload() is so misleading.

The work around for me unfortunately was to just use the firebase sdk directly after update:

try {
  await updateDoc(singleDocRef, {
    ffo: 'bar'
  });
  const mySnap = await getDocs(mySnapRef);
  const myData = mySnap.docs.map(d => d.data());

  // Look at myData, not your open web socket data
} catch(e) {
}

@ZakKa89
Copy link
Author

ZakKa89 commented Oct 27, 2024

If that works, can we conclude the issue lies with react-firebase-hooks and this is an actual bug with the library?

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