[2:41 PM, 10/18/2020] Dhruv Tushii's Frnd: Use Effect will call everytime theres a change in application [2:41 PM, 10/18/2020] Dhruv Tushii's Frnd: Add empty array code example
Example 1: useeffect componentdidmount
import React, { useState, useEffect } from 'react';
function Example() {
const [count, setCount] = useState(0);
useEffect(() => {
document.title = `You clicked ${count} times`;
});
);
}
Example 2: useeffect componentdidmount
useEffect(() => {
messagesRef.on('child added', snapshot => {
const message = snapshot.val();
message.key = snapshot.key;
setMessages(messages.concat(message));
}, []);