I'm currently doing this to conditionally render certain Components:
render() { return ( <React.Fragment> <div id="call_notes_app" className="row"> <NavTree onNavChange={this.changeActiveGroup} /> {this.state.shownGroup == 1 && <DiscoveryGroup/>} {this.state.shownGroup == 2 && <FinancialGroup/>} {this.state.shownGroup == 3 && <SalesStuffGroup/>} </div> </React.Fragment> ); } When I try to use a switch statement, it doesn't work (I get ERROR ABORT in the console):
render() { return ( <React.Fragment> <div id="call_notes_app" className="row"> <NavTree onNavChange={this.changeActiveGroup} /> { switch(this.state.shownGroup) { case 1: <DiscoveryGroup/> break; case 2: <FinancialGroup /> break; default: <SalesStuffGroup /> } } </div> </React.Fragment> ); } Is there a way to do this using switch?