I am trying to pass a state variable to a child component as a prop, but the child component is not receiving anything. I saw somewhere that state variables do not update instantly, so I have moved my calls to swap the two child components into the setState callback function. Here's some code..

**Parent Component**

```
//function called by app component to unmount from parent
handleLandingUnmount(enteredCode){
    console.log(enteredCode + ' received in index.js');
    //updating state to give enteredCode to be passed to Chatpage component in props
    this.setState({sessionCode: enteredCode}, function(){
        this.onSessionInState();
    });
}

onSessionInState(){
    console.log(this.state.sessionCode);
    this.setState({renderLandingScreen:false});
    this.setState({renderChatScreen:true});
}

render(){
    //if app component has unmounted, check if chat screen is to be rendered and pass the code as a prop
    const toRender = this.state.renderLandingScreen?<App unmount={this.handleLandingUnmount}/>:
                    this.state.renderChatScreen?<Chatpage sessionCode={this.state.enteredCode}/>:<h1>Something else could go here...</h1>;
    return toRender;
}

```

**Chatpage Component**

```
constructor(props){
    super(props);
    console.log(JSON.stringify(props));
}

render(){ 
    return(
    <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>{this.props.sessionCode}</h2>
        </div>
    </div>
    );
}

```

Thanks in advance for any help.