Created
May 10, 2016 23:26
-
-
Save SteveHoggNZ/0a72e067c97cc1b688fea9dc94a0a772 to your computer and use it in GitHub Desktop.
React Notes
This file contains 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
// Don't use fat arrow functions as props in pure components, use a named function instead e.g. | |
export const ChoiceKey = (props: Props) => { | |
const keyClickHandler = () => { | |
props.keyClick(props.id) | |
} | |
return <div className={classes.choiceKey} | |
onClick={keyClickHandler}>Choice Key {props.id}</div> | |
} | |
// mapActionCreators for redux connect() ... | |
export default connect(mapStateToProps, mapActionCreators)(ChoiceAsTest) | |
// ... can be an object ... | |
const mapActionCreators = { | |
run: () => actions.creators.runRequest(1000000) | |
} | |
// ... or a function that returns an object i.e. where the react component needs to pass arguments to the function | |
const mapActionCreators = (dispatch) => ({ | |
keyClick: bindActionCreators(actions.creators.keyClick, dispatch) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment