|
Download react-use/docs/useGetSetState.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 387 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/docs/useGetSetState.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/docs/useGetSetState.md
-
curl -L -o useGetSetState.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-use/docs/useGetSetState.md
387 Bytes
| # `useGetSetState` | |
| A mix of `useGetSet` and `useGetSetState`. | |
| ## Usage | |
| ```jsx | |
| import {useGetSetState} from 'react-use'; | |
| const Demo = () => { | |
| const [get, setState] = useGetSetState({cnt: 0}); | |
| const onClick = () => { | |
| setTimeout(() => { | |
| setState({cnt: get().cnt + 1}) | |
| }, 1000); | |
| }; | |
| return ( | |
| <button onClick={onClick}>Clicked: {get().cnt}</button> | |
| ); | |
| }; | |
| ``` | |