score:2

Accepted answer
    {context.state.isNavOpen && (
         <div className="js-nav nav">
         ...

score:1

class Toggle extends React.Component {
   state = {
      visibility: false
    }
toggleVisibility=()=>{
 this.setState(prev=>({visibility:!prev.visibility}))
}
  render() {
     const {visibility} = this.state;
      return (
        <div>
          <button onClick={this.toggleVisibility}>Click Me</button>
          <h3>{visibility?'Welcome':''}</h3>
        </div>
      );
    }
};

Related Query

More Query from same tag