🚀 How use • 🛠️ Tools • 📝 Contributing • 🧑 Thanks • 📄 License
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)
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.
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
Wesley Araújo |
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!
redux-state-manage is a open source project licensed as MIT.