React useEffect

The useEffect hook for side effects.

React useEffect Hook

The useEffect Hook allows you to perform side effects in your components.

Some examples of side effects are: fetching data, directly updating the DOM, and timers.

useEffect accepts two arguments. The second argument is optional.

useEffect(<function>, <dependency>)

Example

useEffect(() => {
  // Runs on every render
});