Skip to content

Instantly share code, notes, and snippets.

@yoshi415
Last active September 6, 2018 20:58
Show Gist options
  • Save yoshi415/7e4b3ac2914117be26dce76ff557da0b to your computer and use it in GitHub Desktop.
Save yoshi415/7e4b3ac2914117be26dce76ff557da0b to your computer and use it in GitHub Desktop.
// previous
componentWillMount() {
const { fetchSchedule, someOtherMethod, taskerInfo: { user_id } } = this.props;
fetchSchedule(user_id);
someOtherMethod();
}
export default connect(mapStateToProps, {
...recommendationActions,
...taskerScheduleActions,
...calendarActions,
})(TaskerScheduleModal);
// proposed
import { bindActionCreators } from 'redux';
componentWillMount() {
const { calendarActions, taskerScheduleActions, taskerInfo: { user_id } } = this.props;
taskerScheduleActions.fetchSchedule(user_id);
calendarActions.someOtherMethod();
}
const mapDispatchToProps = dispatch => ({
recommendationActions: bindActionCreators(recommendationActions, dispatch),
taskerScheduleActions: bindActionCreators(taskerScheduleActions, dispatch),
calendarActions: bindActionCreators(calendarActions, dispatch),
});
export default connect(mapStateToProps, mapDispatchToProps)(
TaskerScheduleModal
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment