firebase / firebase/firebaseui-web-react

Callback come faster then setState

Aperta
#148 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
1.3k
Fork
246
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Hi all,
I am trying to setState the value of callback on data change,
The issue that the callback is faster then my setState ,
that making the prev state to update not correct values,
What can be done?

```
commentsRef.on("child_changed", (data) => {

if (guests) {
const key = data.key;
const updatedGuest = data.val();
//guests ->isnt updated from last trigger
const cloneGuests =_.cloneDeep(guests);
cloneGuests.forEach((element, index) => {
if (element.guestID === key) {
cloneGuests[index] = updatedGuest;
}
});
setGuests(cloneGuests);
}
});
```

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.