I am trying to render some complex tertiary logic that organizes my application's components in the correct order. It keeps giving me an error at the bracket immediately after the render method.
I've found the same error described for similar situations on this website, but the solutions didn't help mine. Most of the troubleshooting I read about involved fixing how/where people called methods but this script is only running render. Additionally I made sure to wrap it in one tag and use className instead of class and all other JSX related syntax bug fixes.
Here is my App.js: I am passing along functions into the other components that toggle their respective states of the same name between true and false determining which gets rendered.
import React, { Component } from 'react';
import './index.css';
import Game from './Game.js'
import Homescreen from './Homescreen.js'
import PlayerScreen from './Playerscreen.js'
class App extends Component {
constructor(props){
super(props);
this.state = {
Homescreen: true,
PlayerScreen: false,
Game: false,
players: [{
users: '',
points: 0,
}]
}
render() {
return (
<div>
{
(this.state.Homescreen) ?
<div id="wrapper">
<Homescreen newScreen={()=>this.setState({Homescreen: false, PlayerScreen: true})}></Homescreen>
</div> : (this.state.PlayerScreen) ? <div id="wrapper">
<PlayerScreen players={this.state.players} start={(players)=>this.setState({PlayerScreen: false, Game: true, players: players})}></PlayerScreen>
</div> : <div id="wrapper"><Game players={this.state.players}></Game></div>
}
</div>
);
}
}
}
export default App;
Error message:
Failed to compile.
./src/App.js
Line 20:12: Parsing error: Unexpected token, expected ";"
18 | }
19 |
> 20 | render() {
| ^
21 | return (
22 | <div>
23 | {
Any help would be greatly appreciated.