Skip to content

Instantly share code, notes, and snippets.

@peterkle
Last active September 1, 2017 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterkle/d1597b4614c00493e3a685c77f095952 to your computer and use it in GitHub Desktop.
Save peterkle/d1597b4614c00493e3a685c77f095952 to your computer and use it in GitHub Desktop.
React component example
// <ToggleSwitch />
class ToggleSwitch extends Component {
onClickHandler = () => {
this.setState((prevState) => ({ on: !prevState.on }));
this.props.clickHandler();
}
// …
}
// Elsewhere in app
<ToggleSwitch clickHandler={this.props.UiState.doSomething} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment