class Dashboard extends React.Component{
constructor(props){
super(props);
this.state = {navigation : ''}
}
render(){
return(
<div className="wrapper">
<Navigation onNavigationChange={this.onNavigationChange.bind(this)}/>
<main>
<TopBar navigation={this.state.navigation}/>
<div className="content">
<MiddleBar/>
{this.props.children}
</div>
<Footer />
</main>
</div>
);
}
onNavigationChange(selectedValue){
this.setState({navigation : 'selectedValue'});
debugger;
}
}
export default Dashboard;
我正在將導航的ChangeChange回調傳遞給我的導航內容。它調用並返回所選狀態的值。但是當我嘗試setState this.setState({navigation:selectedValue})狀態沒有得到更新。setState沒有更新狀態