Created
December 11, 2015 14:25
-
-
Save dylansmith/36954cb1b47e539b1161 to your computer and use it in GitHub Desktop.
Minimal-boilerplate redux actionCreator pattern, using redux-actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createAction } from 'redux-actions' | |
export const SOME_ACTION = 'SOME_ACTION' | |
export const ANOTHER_ACTION = 'ANOTHER_ACTION' | |
const actionCreators = { | |
someAction: () => createAction(SOME_ACTION/*, ...*/), | |
anotherAction: () => createAction(ANOTHER_ACTION/*, ...*/) | |
} | |
export default actionCreators |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component, PropTypes} from 'react' | |
import {connect} from 'react-redux' | |
import actionCreators from './actions' | |
const mapState = (state) => { | |
return { | |
//... | |
} | |
} | |
const mapActions = { | |
...actionCreators | |
} | |
@connect(mapState, mapActions) | |
export default class SomeComponent extends Component { | |
componentWillMount() { | |
this.props.someAction() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment