firebase / firebase/firebaseui-web-react
Callback come faster then setState
- 主要言語
- JavaScript
- スター
- 1.3k
- フォーク
- 246
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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);
}
});
```
コントリビューションガイド
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- firebase, javascript, react
- 領域
- frontend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100