Epic React V2

Side Effects

(Read only)

Good to keep the function inside the useEffect, internally, because of the dependencies are trigger when something has changed.

useEffect(() => { // your side-effect code here. // this is where you can interact with browser APIs for example doSomeThing() return function cleanup() { // if you need to clean up after your side-effect (like unsubscribe from an // event), you can do it here doSomeCleanup() } }, [ // this is where dependencies of your useEffect callback go // we'll talk about this in depth in a future exercise. // In this exercise, we'll just leave it as an empty array dep1, dep2, ])