
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
redux-action-wrapper
Advanced tools
This simplifies your mapDispatchToProps and removes a significant amount of boilerplate by wrapping your action modules with the dispatch function. It takes an object that contains functions and returns those functions wrapped in the dispatch method. The object is traversed recursively. Non-functions are ignored.
The action wrapper is only used in the mapDispatchToProps function that you pass to redux's connect.
import actionWrapper from 'redux-action-wrapper';
function mapDispatchToProps (dispatch) {
return actionWrapper({
userActions,
modalActions,
randomAction: () => ({type: 'MY_ACTION'})
}, dispatch);
}
Only one function is provided.
var actions = actionWrapper(actionsObject, dispatch)
actionsObject is an object, possibly nested, containing action functions.dispatch is the dispatch method provided by react-redux.The actions object returned can be returned from mapDispatchToProps directly.
All functions on the object passed to actionWrapper are wrapped in the dispatch function provided by Redux. You access them through this.props.
// for the root level
this.props.actionName();
// for nested objects
this.props.userActions.load();
// and double nested is the same
this.props.userActions.preferences.setCity('NYC');
import React from 'react';
import { connect } from 'react-redux';
import * as userActions from 'path/to/userActions';
import * as modalActions from 'path/to/modalActions';
import actionWrapper from 'redux-action-wrapper';
class MyComponent extends React.Component {
componentDidMount () {
if (!this.props.user) {
this.props.userActions.load(); // <---- ACTION USAGE
}
this.props.randomAction(); // <------------ ACTION USAGE
}
render () {
if (this.props.user) {
return (<span>{this.props.user.name}</span>);
} else {
return (<span>Loading...</span>);
}
}
}
function mapDispatchToProps (dispatch) {
return actionWrapper({ // <---------- ACTION WRAPPER IS HERE
userActions,
modalActions,
randomAction: () => ({type: 'MY_ACTION'})
}, dispatch);
}
function mapStoreToProps (store) {
return store;
}
export default connect(mapStoreToProps, mapDispatchToProps)(MyComponent);
FAQs
Simplifies mapDispatchToProps significantly
We found that redux-action-wrapper 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.