firebase / firebase/firebaseui-web-react

Callback come faster then setState

Abierto
#148 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
1.3k
Forks
246
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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);
}
});
```

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

No file or test is named. Start with the commentsRef.on("child_changed") callback and the setGuests call shown in the issue, then trace how guests is captured across repeated callbacks. Done means successive child_changed events retain earlier updates and guests reflects each changed guest.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
firebase, javascript, react
Área
frontend
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.