Skip to content

Instantly share code, notes, and snippets.

@dylansmith
Created December 11, 2015 14:25
Show Gist options
  • Save dylansmith/36954cb1b47e539b1161 to your computer and use it in GitHub Desktop.
Save dylansmith/36954cb1b47e539b1161 to your computer and use it in GitHub Desktop.
Minimal-boilerplate redux actionCreator pattern, using redux-actions
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
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