DEV Community

Cover image for useEffect, what you don't know
Ifeanyi Chima
Ifeanyi Chima

Posted on

useEffect, what you don't know

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

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

SurveyJS custom survey software

JavaScript UI Libraries for Surveys and Forms

SurveyJS lets you build a JSON-based form management system that integrates with any backend, giving you full control over your data and no user limits. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay