this is my game component
class GameRoom extends Component{
constructor(){
super();
this.state ={
inGame: true,
player2:false,
}
}
componentDidMount() {
this.game = new init(this)
}
render(){
return(
<div>
<Fragment className="room">
<div id="container" />
</Fragment>
</div>
);
}
}
export default GameRoom;
this is my main
class Main extends Component {
constructor(){
super();
this.state ={
inGame:false,
player2:false
};
}
changeState(inGame,player2){
this.setState({
inGame:inGame,
player2:player2
});
}
componentDidMount(){
}
render(){
console.log(this.state.player2)
if (this.state.inGame===false){
return (
<div className="Home">
<div className="Contenido">
< CardLogin onChangeState={this.changeState.bind(this)}/>
</div>
</div>
); }
else{
const Height = window.innerHeight;
return(
<Scrollbars style={{ height: Height }} >
<div className="GameRoom">
<Navegation/>
<GameRoom/>
<Footer/>
</div>
</Scrollbars>
);
}
}
}
export default Main;
the component cardlogin change the state, but in gameroom the state does not change