Skip to main content

Command Palette

Search for a command to run...

Explain about types of side effects in React component.

Updated
1 min read
Explain about types of side effects in React
component.

There are two common kinds of side effects in React components: those that don’t require cleanup, and those that do.

Effects Without Cleanup

Sometimes, we want to run some additional code after React has updated the DOM. Network requests, manual DOM mutations, and logging are common examples of effects that don’t require a cleanup.

Effects with Cleanup

We might want to set up a subscription to some external data source. In that case, it is important to clean up so that we don’t introduce a memory leak!

Sources:

Using the Effect Hook –. (n.d.). React. https://reactjs.org/docs/hooks-effect.html

More from this blog

R

Raja Muhammad Asher - Senior Software Engineer - Full Stack Developer

157 posts

Full Stack Developer with a passion for building web applications. PHP, Node.js, Laravel, ExpressJS, MySQL, MongoDB. Love collaborating & making a difference

Explain about types of side effects in React component.