Installation
yarn add react-redux-connect
Usage
Store all connect
options as a static attributes inside your component.
import connect from 'react-redux-connect';
import { actionOne, actionTwo } from './actions';
export class MySmartComponent {
static mapStateToProps(state, ownProps) {
return {
};
}
static mapDispatchToProps(dispatch, ownProps) {
return {
actionOne,
actionTwo,
};
}
static mergeProps(stateProps, dispatchProps, ownProps) {
return {
}
}
static connectOptions = {
};
render() {
}
}
export default connect(MySmartComponent);
Example below is the same to following:
import { connect } from 'react-redux';
import { actionOne, actionTwo } from './actions';
const mapStateToProps = (state, ownProps) => {
return {
};
};
const mapDispatchToProps = (dispatch, ownProps) => {
return {
actionOne,
actionTwo,
};
};
const mergeProps = (stateProps, dispatchProps, ownProps) => {
return {
}
};
const connectOptions = {
};
export class MySmartComponent {
render() {
}
}
export default connect(mapStateToProps, mapDispatchToProps, mergeProps, connectOptions)(MySmartComponent);
Licence
MIT
Testing
yarn test
Contributing
You are welcome! :)