> For the complete documentation index, see [llms.txt](https://bret-maxime.gitbook.io/reactjrx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bret-maxime.gitbook.io/reactjrx/utils/react/useeffectonce.md).

# useEffectOnce

React lifecycle hook that runs an effect once, when the component mounts.

{% hint style="warning" %}
In development, under `<StrictMode>`, React mounts each component twice. So the effect runs twice, with its cleanup between the two runs. Make the cleanup undo the effect.
{% endhint %}

### Usage <a href="#usage" id="usage"></a>

```jsx
import {useEffectOnce} from 'reactjrx';

const Demo = () => {
  useEffectOnce(() => {
    console.log('Running effect once on mount')

    return () => {
      console.log('Running clean-up of effect on unmount')
    }
  });

  return null;
};
```

### Reference <a href="#reference" id="reference"></a>

```js
useEffectOnce(effect: EffectCallback);
```
