Skip to content

Instantly share code, notes, and snippets.

@88atwilliams
Created January 28, 2019 02:26
Show Gist options
  • Save 88atwilliams/455ba210ff643340b9a0aaa9119d820d to your computer and use it in GitHub Desktop.
Save 88atwilliams/455ba210ff643340b9a0aaa9119d820d to your computer and use it in GitHub Desktop.
import React, {Component, Fragment} from 'react'; components/utilities/toggle.js
class Toggle extends Component {
state = {
on: false
};
toggle = ()=> {
this.setState({
on: !this.state.on
});
console.log("on", this.state.on)
};
render() {
const {render} = this.props;
return (
<> !--> this is Fragment if you havent seen them look it up! they rock!
{
render(
{
on: this.state.on,
toggle: this.toggle
}
)
}
</>
)
}
}
export default Toggle;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment