Last active
November 6, 2021 22:36
-
-
Save szaranger/a0b0f22710e19867e0bede94899358c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from 'react'; | |
function MyComponent() { | |
useEffect(() => { | |
// Run once after DOMContentEvent loads | |
}, []); | |
useEffect(() => { | |
// Synchronize the state with the state of this component. | |
return function cleanup() { | |
// Cleanup the previous side-effect before running a new one | |
} | |
// Run the side-effect and it's cleanup to for the re-run | |
}, [a, b ,c, d]); // When any of these change | |
useEffect(() => { | |
// Run every single time this component is re-rendered | |
}); | |
return { | |
// Render React elements | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment