I'm trying to do a conditional where the active component depends on a state variable.
this.state = {
display: 0,
}
State 0 is the initial state, which is changed when the user clicks a button.
Depending on the button the display variable will change to a value from 1 to 4.
{if (this.state.display == '0') {
return ()
} else if (this.state.display == '1') {
return()
} else if (this.state.display == '2') {
return()
} else if (this.state.display == '3') {
return()
} else if (this.state.display == '4') {
return(
<Catalogo></Catalogo>
)}
}}
The full code can be found at github / cmoutella
The error says 'Parsing error: Unexpected token' and points to if.
How can I do this?