const someFunction = () => { // do anything in the function } function TheComponent() { useEffect(someFunction) // you pass the function you want to run after every render return <div>.....</div> } // However, generally this whole process is short-circuited by using // an anonymous arrow function directly in useEffect() function TheComponent() { useEffect(() => { // do anything you want to do here. }) return <div>.....</div> }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter