Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 405 Bytes

useEffectOnce.md

File metadata and controls

27 lines (19 loc) · 405 Bytes

useEffectOnce

React的生命周期钩子,只运行一次效果。

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);