Skip to content

Instantly share code, notes, and snippets.

@damienwebdev
Created May 18, 2016 19:31
Show Gist options
  • Save damienwebdev/d8b8c46d9d10b2fc06e65b752a55c51b to your computer and use it in GitHub Desktop.
Save damienwebdev/d8b8c46d9d10b2fc06e65b752a55c51b to your computer and use it in GitHub Desktop.
import { connect } from 'react-redux'
import { toggleChoice } from '../actions/index'
import ChoiceSet from '../components/ChoiceSet';
const getChoices = (choices, choiceType) => {
return choices.filter(t => t.choiceType == choiceType)
};
const mapStateToProps = (state) => {
return {
choices: getChoices(state.choices, this.props.choiceType)
}
};
const mapDispatchToProps = (dispatch) => {
return {
onChoiceClick: (id) => {
dispatch(toggleChoice(id, this.props.choiceType))
}
}
};
const QuizChoiceSet = connect(
mapStateToProps,
mapDispatchToProps
)(ChoiceSet);
export default QuizChoiceSet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment