firebase / firebase/firebaseui-web-react

Callback come faster then setState

Đang mở
#148 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
JavaScript
Star
1.3k
Fork
246
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
firebase, javascript, react
Lĩnh vực
frontend
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.