Execute when component render, update and destroy
Eg:
function Parent() {
const [count, setCount] = useState(0)
useEffect(() => {
console.warn("use effect")
})
return (
<>
<h1>useEffect in React {count}</h1>
<button onClick={() => setCount(count + 1)}>Update Counter</button>
</>
);
}
© www.thecoderjob.com. All Rights Reserved. Designed by HTML Codex