redux-state-manage
v1.0.2
Published
Redux State Manage (RSM) is a solution for easy implements Redux in your project.
Downloads
1
Readme
:rocket: How use
Instalation:
npm install redux-state-manage
#or
yarn add redux-state-manage
Answer the questions (When choosing the tool, use the arrows keys to navigate, the spacebar to select and enter to finish)
🛠️ Utilization
For state handling, we will use useReduxState
as a replacement for useState.
import { useReduxState } from 'redux-state-manage';
const App = () => {
const [state, useMutateState] = useReduxState('stateName', 'initialValue');
return (
<div>
<h1>{state}</h1>
<button onClick={() => useMutateState('stateName', 'new value')}>Change state</button>
</div>
);
};
For fetching data, we will use useReduxFetch
as a replacement for useEffect.
import { useReduxFetch, useMutateFetch, fetcher } from 'redux-state-manage';
const App = () => {
// the id is unique for each request
const { data, error, isLoading } = useReduxFetch(
"http://localhost:3333",
"data",
fetcher
);
return (
<div>
<h1>{data} - {error} - {isLoading}</h1>
<button onClick={() => useMutateFetch('http://localhost:3333', 'data', fetcher)}>Change data</button>
</div>
);
};
The two main methods were inspired by useState
and SWR
, using redux as the state manager.
:pencil: Contributing
Your contribution to the redux-state-manage
is essential for the evolution of the project, you can do it as follows:
- Open an issue to clear doubts, report bugs or give ideas
- Open a pull request to give ideas for code improvement, implementation of new features and bug fixes
These are just some of the ways you can contribute to the project read the CONTRIBUTING for more information
:adult: Authors
✨ Contributors
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
:page_facing_up: License
redux-state-manage is a open source project licensed as MIT.