![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
react-redux-action-dispatchers-hook
Advanced tools
Short: Transform action creators into action dispatchers
This simple make the code a tiny more clean. (See example's)
See demo here (editable codesandbox.io)
import React, { FC } from "react";
import useCreateActionDispatchers from "react-redux-action-dispatchers-hook";
const MyActionCreators = {
action1: (name: string) => ({ type: "action1", name }),
action2: (num: number) => ({ type: "action2", num })
};
export const useMyActions = () => useCreateActionDispatchers(MyActionCreators);
export const MyComponent: FC = () => {
const { action1, action2 } = useMyActions();
return (
<div>
<button onClick={() => action1("SomeName")}>Action 1</button>
<button onClick={() => action2(42)}>Action 2</button>
</div>
);
};
Or you can add properties for the area with useCreateArea
import { useCreateArea } from "react-redux-action-dispatchers-hook";
//(...)
export const useMyActions = () =>
useCreateArea(MyActionCreators, (state: IStore) => state.area);
export const MyComponent: FC = () => {
const { prop1, prop2, action1, action2 } = useMyActions();
return (
<div>
<button onClick={() => action1("SomeName")}>{prop1}</button>
<button onClick={() => action2(42)}>{prop2}</button>
</div>
);
};
npm install react-redux-action-dispatchers-hook
Or
yarn add react-redux-action-dispatchers-hook
Create a plainObject with all your action creators like 'MyActionCreators'
const MyActionCreators = {
action1: (name: string) => ({ type: "action1", name }),
action2: (num: number) => ({ type: "action2", num })
};
Or
// action-creators are defined other place
const MyActionCreators = {
action1,
action2
};
Create hook by passing the plainObject into CreateActionDispatchers
import CreateActionDispatchers from "react-redux-action-dispatchers-hook";
export const useMyActions = () => CreateActionDispatchers(MyActionCreators);
The action dispatcher can now be called the same way as the original action creators,
but they will also dispatch them (using reacts useDispatch
)
const MyComponent: FC = () => {
const { action1, action2 } = useMyActions();
return (
<div>
<button onClick={() => action1("SomeName")}>Action 1</button>
<button onClick={() => action2(42)}>Action 2</button>
</div>
);
};
The code below does the same thing.
As you can see, the only thing react-redux-action-dispatchers-hook
does is making the code a little more clean.
const MyComponent: FC = () => {
const dispatch = useDispatch();
const { action1, action2 } = MyActionCreators;
return (
<div>
<button onClick={() => dispatch(action1("SomeName"))}>Action 1</button>
<button onClick={() => dispatch(action2(42))}>Action 2</button>
</div>
);
};
FAQs
transform action creators into action dispatchers
We found that react-redux-action-dispatchers-hook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.