question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sometimes duplicate keys appear in useList after database insertion

See original GitHub 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!)

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
rayoverweijcommented, Jul 6, 2022

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.

2reactions
rayoverweijcommented, Jun 10, 2022

I see the same, and also with useListVals.

Read more comments on GitHub >

github_iconTop Results From Across the Web

insert - SQL Server - simple discard of duplicate keys
Just add a WHERE NOT EXISTS to the statement you're executing - INSERT INTO table VALUES('123', 'blah') WHERE NOT EXISTS(select top 1 from ......
Read more >
13.2.7.2 INSERT ... ON DUPLICATE KEY UPDATE Statement
If you specify an ON DUPLICATE KEY UPDATE clause and a row to be inserted would cause a duplicate value in a UNIQUE...
Read more >
Basic Relationship Patterns — SQLAlchemy 2.0 Documentation
Basic Relationship Patterns¶. A quick walkthrough of the basic relational patterns, which in this section are illustrated using Declarative ...
Read more >
Multisim User Guide
BECAUSE EACH END-USER SYSTEM IS CUSTOMIZED AND DIFFERS FROM. NATIONAL INSTRUMENTS' TESTING PLATFORMS AND BECAUSE A USER OR APPLICATION DESIGNER MAY USE NATIONAL ......
Read more >
How to Skip Duplicate Key Errors (ORA-00001) in Oracle ...
Use this as the target for foreign keys." Creating unique constraints improves data quality. Usually when someone tries to insert an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found