Wednesday, February 19, 2020

Javscript, React - Simple React Toggle Example


state = {
showSomething: false
}

toogleSomething = () => {

const holder = this.state.showSomething;
this.setState({showSomething: !holder});
//Holder holds the previous value so that the next time you call the function it will be updated with the other new state value and therefore toggle. }

No comments:

Post a Comment