An open API service indexing awesome lists of open source software.

https://github.com/majidux/usestates

A custom hook for having multiple states. This package can only use in Reactjs.
https://github.com/majidux/usestates

hooks react react-hooks react-native reactjs strategy-design-pattern

Last synced: 9 months ago
JSON representation

A custom hook for having multiple states. This package can only use in Reactjs.

Awesome Lists containing this project

README

          

# useStates

A custom hook based on useReducer and inspired by strategy design pattern for having multiple states

###### With npm:
```javascript
npm install --save use-states-react
```

###### With yarn:
```javascript
yarn add use-states-react
```

This is how you are going to use it : =>
```javascript
import { useStates } from "use-states-react";

const initialState = {
name: "",
};

const Example = () => {
const [state, setState] = useStates(initialState);
const { name } = state;
const onChange = ({ target: { name, value } }) => {
setState(
{
[name]: value,
},
() => console.log("Callback function")
);
};
return (
<>

>
);
};
```