react-recipes
Version:
A React Hooks utility library containing popular customized hooks
45 lines (35 loc) • 605 B
Markdown
and read an Array
- `initialValue: Array`: init of array
```
{
add,
clear,
removeIndex,
removeById,
value,
setValue
}
```
```jsx
import { useArray } from 'react-recipes';
function App {
const {
add,
clear,
removeIndex,
removeById,
value: currentArray
} = useArray(['cat','dog','bird']);
return (
<>
<button onClick={() => add('tiger')}>Add animal</button>
<button onClick={() => removeIndex(2)}>Remove Bird</button>
<button onClick={clear}>Clear</button>
</>
)
};
```
Manipulate