--- title: Render with an If-Else Condition --- # Render with an If-Else Condition --- ## Solutions
Solution 1 (Click to Show/Hide) ```jsx class MyComponent extends React.Component { constructor(props) { super(props); this.state = { display: true } this.toggleDisplay = this.toggleDisplay.bind(this); } toggleDisplay() { this.setState({ display: !this.state.display }); } render() { // change code below this line if (this.state.display) { return (

Displayed!

); } else { return (
); } } }; ```