oz-redux-dispatcher
v1.0.0
Published
This utility get all actions into useDispatch hook.
Downloads
4
Maintainers
Readme
oz-redux-dispatcher
This utility get all actions into useDispatch hook.
Uses oz-redux-reducer
Works with:
Example:
Install:
First follow instruction of oz-redux-reducer
npm i oz-redux-dispatcher
Usage:
in store/actions/index.ts
file:
import { useDispatchActions } from "oz-redux-dispatcher";
import { demoActions } from "../reducers/demo-reducer";
export const useDemoActions = () => useDispatchActions(demoActions);
calling actions:
import { useDemoActions } from "../store";
export default function ShowText({ text = "" }: { text?: string }) {
const { dispatchSetText } = useDemoActions();
return <button onClick={() => dispatchSetText(text)}>Set text</button>;
}