react-use/docs/useGetSetState.md
Nicolas Girault 6e3a73a1e6
Fix typo
2020-12-31 20:30:46 +01:00

24 lines
387 B
Markdown

# `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>
);
};
```