mirror of
https://github.com/streamich/react-use.git
synced 2025-12-08 18:02:14 +00:00
28 lines
402 B
Markdown
28 lines
402 B
Markdown
# `useEffectOnce`
|
|
|
|
React lifecycle hook that runs an effect only once.
|
|
|
|
## Usage
|
|
|
|
```jsx
|
|
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
|
|
|
|
```js
|
|
useEffectOnce(effect: EffectCallback);
|
|
```
|