Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 402 Bytes

useEffectOnce.md

File metadata and controls

27 lines (19 loc) · 402 Bytes

useEffectOnce

React lifecycle hook that runs an effect only once.

Usage

import {useEffectOnce} from 'react-use';

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

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

  return null;
};

Reference

useEffectOnce(effect: EffectCallback);