https://github.com/dusanjovanov/use-reducer-actions
Simplified useReducer
https://github.com/dusanjovanov/use-reducer-actions
hook react use-reducer
Last synced: about 1 month ago
JSON representation
Simplified useReducer
- Host: GitHub
- URL: https://github.com/dusanjovanov/use-reducer-actions
- Owner: dusanjovanov
- License: mit
- Created: 2022-07-22T21:27:45.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-07-22T21:47:20.000Z (almost 3 years ago)
- Last Synced: 2025-02-28T04:04:40.270Z (about 2 months ago)
- Topics: hook, react, use-reducer
- Language: TypeScript
- Homepage:
- Size: 130 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# use-reducer-actions
Hook which simplifies `useReducer`
[](https://www.npmjs.com/package/@dusanjovanov/use-reducer-actions)
```bash
npm i @dusanjovanov/use-reducer-actions
``````bash
yarn add @dusanjovanov/use-reducer-actions
```## Features
- Tiny `312B`
- Full Typescript support## Usage
```tsx
import { useReducerActions } from '@dusanjovanov/use-reducer-actions';const Counter = () => {
const [state, actions] = useReducerActions({
initialState: {
count: 0,
},
reducers: {
increment: state => {
return {
...state,
count: state.count + 1,
};
},
setCount: (state, payload: number) => {
return {
...state,
count: payload,
};
},
},
});return (
Count: {state.count}
Increment
actions.setCount(3)}>Set count to 3
);
};
```