Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

useeffect componentdidmount

useEffect(() => {
    messagesRef.on('child added', snapshot => {
    const message = snapshot.val();
    message.key = snapshot.key;

    setMessages(messages.concat(message)); // See Note 1
}, []); // See Note 2
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #useeffect #componentdidmount
ADD COMMENT
Topic
Name
5+3 =