|
Download react-use/docs/useDeepCompareEffect.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 575 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useDeepCompareEffect.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-use/docs/useDeepCompareEffect.md
-
curl -L -o useDeepCompareEffect.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-use/docs/useDeepCompareEffect.md
575 Bytes
| # `useDeepCompareEffect` | |
| A modified useEffect hook that is using deep comparison on its dependencies instead of reference equality. | |
| ## Usage | |
| ```jsx | |
| import {useCounter, useDeepCompareEffect} from 'react-use'; | |
| const Demo = () => { | |
| const [count, {inc: inc}] = useCounter(0); | |
| const options = { step: 2 }; | |
| useDeepCompareEffect(() => { | |
| inc(options.step) | |
| }, [options]); | |
| return ( | |
| <div> | |
| <p>useDeepCompareEffect: {count}</p> | |
| </div> | |
| ); | |
| }; | |
| ``` | |
| ## Reference | |
| ```ts | |
| useDeepCompareEffect(effect: () => void | (() => void | undefined), deps: any[]); | |
| ``` | |