1.0.2 • Published 8 months ago

redux-state-manage v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Open Source Love MIT Licence npm version npm downloads All Contributors

: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.

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

3.0.1

5 years ago

2.2.1

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago