Effects are an escape hatch from the React paradigm.

They let you “step outside” of React and synchronize your components with some external system like a non-React widget, network, or the browser DOM.

If there is no external system involved (for example, if you want to update a component’s state when some props or state change), you shouldn’t need an Effect. Removing unnecessary Effects will make your code easier to follow, faster to run, and less error-prone.

How to remove unnecessary Effects

There are two common cases in which you don’t need Effects:

<aside> 💡 You do need Effects to synchronize with external systems.

</aside>

For example, you can write an Effect that keeps a jQuery widget synchronized with the React state. You can also fetch data with Effects: for example, you can synchronize the search results with the current search query.

Keep in mind :

⇒ that modern frameworks provide more efficient built-in data fetching mechanisms than writing Effects directly in your components.

To help you gain the right intuition, let’s look at some common concrete examples!

Updating state based on props or state

When something can be calculated from the existing props or state

**don’t put it in state.**

Instead, calculate it during rendering.