📅  最后修改于: 2022-03-11 14:56:28.398000             🧑  作者: Mango
useEffect(() => {
messagesRef.on('child added', snapshot => {
const message = snapshot.val();
message.key = snapshot.key;
setMessages(messages.concat(message)); // See Note 1
}, []); // See Note 2