mirror of
https://github.com/streamich/react-use.git
synced 2026-01-18 14:06:52 +00:00
23 lines
373 B
Markdown
23 lines
373 B
Markdown
# `useList`
|
|
|
|
React state hook that tracks a value of an array.
|
|
|
|
|
|
## Usage
|
|
|
|
```jsx
|
|
import {useList} from 'react-use';
|
|
|
|
const Demo = () => {
|
|
const [list, {set, push}] = useList();
|
|
|
|
return (
|
|
<div>
|
|
<div>{list.join(',')}</div>
|
|
<button onClick={() => set([])}>Reset</button>
|
|
<button onClick={() => push(Date.now())}>Push</button>
|
|
</div>
|
|
);
|
|
};
|
|
```
|