-
Notifications
You must be signed in to change notification settings - Fork 306
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
Sometimes duplicate keys appear in useList after database insertion #245
Comments
+1 |
I see the same, and also with |
I have the same problem, do you have any news? |
Hi - from my experience so far, it only seems to happen in development environments, not in production. I haven't had time to look at this repo's source code yet, but as the bug appeared after upgrading to React 18 (I think), my guess it that it has something to do with React running effects twice in development mode now, and that interfering with how RFH works. It hasn't been a breaking issue for us as, as mentioned, it only appears in dev for me (as far as I can see, at least), but still, it's very annoying. |
Seeing it myself with NextJS app. Kind of concerning, makes me think the hooks don't clean themselves properly when unmounting. |
I'm seeing this with React 18.2.0 |
+1 |
1 similar comment
+1 |
even worse, I get triggered twice for some of the keys, first with the old v.val() and then with the old value. So I have to manually ignore the second trigger... |
I got the same problem with useListVal in dev mode (firebase emulator). |
+1 when using useListVals |
Also happens here when using useListVals |
I fixed this problem by replacing useEffect cleanup function in useList.ts file to: |
We're also seeing duplicate keys with useList. It's annoying having to check for and remove duplicates. Any ETA on this? |
+1 |
I added a PR to manage the issue |
I've noticed this issue intermittently:
When a new record is added to the realtime database, it shows up multiple times in the list when using
useList
. When I refresh the page, it will go back to only being shown once. This has happened for multiple different views of useList (a data table, a custom component, etc), and I'm confident it's caused by a single key appearing multiple times in the data snapshot.This has happened in two different apps of mine, a normal react project and a react native project.
I haven't been able to consistently reproduce this, but it's happened frequently enough that I bet it happens to other users. Has anyone noticed this happening to them?
(This is a very useful library by the way, thank you for creating it!)
The text was updated successfully, but these errors were encountered: