I have a React component, and inside the render method of the component I have something like this:
render() { return ( <div> <div> // removed for brevity </div> { switch(...) {} } <div> // removed for brevity </div> </div> ); } Now the point is that I have two div elements, one at the top and one at the bottom, that are fixed. In the middle I want to have a switch statement, and according to a value in my state I want to render a different component. So basically, I want the two div elements to be fixed always, and just in the middle to render a different component each time. I'm using this to implement a multi-step payment procedure). Though, as is the code currently it doesn't work, as it gives me an error saying that switch is unexpected. Any ideas how to achieve what I want?
returnstatement or even therendermethod for that matter. Could you define each<div>as a const, and then use theswitchbefore yourreturnto determine which<div>should be rendered?divat the top and bottom, multiple times for each case of theswitch. Or I just misunderstood, you..let middleDiv = ...and then include{middleDiv}in your return JSX between the two<div>s that you have hard-coded there.