react-redux-action-provider
v1.0.3
Published
Serves this.context.actions bound to Redux store
Readme
This context provider component maps your action creators to your Redux store, and provides them to the child components through this.context.actions.
This saves you writing mapDispatchToProps boilerplate in every component.
Install
$ npm install react-redux-action-providerUsage
actions.js
export function signIn() {
dispatch => {
// Sign in
}
}
export function signOut() {
dispatch => {
// Sign out
}
}index.js
import {
signIn,
signOut
} from './actions';
import ActionProviderCreator from 'react-redux-action-provider';
const ActionProvider = ActionProviderCreator({
signIn,
signOut
});- <Provider store={store}>
- <App />
- </Provider>
+ <Provider store={store}>
+ <ActionProvider>
+ <App />
+ </ActionProvider>
+ </Provider>MyComponent.js
+ MyComponent.contextTypes = {
+ actions: PropTypes.object
+ };render() {
// this.context.actions.signIn();
// this.context.actions.signOut();
}