Quantcast
Channel: How do you change what jsx blocks are being rendered from inside a same class? - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Filip Wojciechowski for How do you change what jsx blocks are being rendered from inside a same class?

$
0
0

Put the conditional logic inside the render() method.

Something like this...

class Example extends React.Component {  // the rest of your code  render() {     const { mode } = this.state;          return(<div>                 {mode ==="on"&& <button onClick={this.flipOn}>State: On</button> }                 {mode === "off"&& <button onClick={this.flipOff}>State: Off</button>}</div>          )    }}

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>