useEffect, what you don't know

Ifeanyi Chima - Mar 27 '23 - - Dev Community

useEffect in react is used to handle asynchronous code. what does this mean, asynchronous tasks means things you have to wait for, such as fetching data from an API.

Here are a few things to note about useEffect

1 It will run only at load time, if the dependency array is empty.

2 It will run everytime the component re-renders if you do not include a dependency array.

3 It will run everytime the dependency array changes.

4 Clean up function:This runs everytime the component un-mounts. The callback of useEffect returns a clean-up function which ou can use for various things such as clearIntervals, cancel API request.

Buy Me A Coffee

Thank you, Please follow me

HTML GitHub

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player