Created
May 18, 2016 19:31
-
-
Save damienwebdev/d8b8c46d9d10b2fc06e65b752a55c51b to your computer and use it in GitHub Desktop.
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 { 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