render(){
const isLoggedIn = this.state.isLoggedIn;
console.log("isLoggedIn:"+isLoggedIn);
let button = null;
if (isLoggedIn){
button = LogoutButton onClick={this.handleLogoutClick}
}else{
button = LoginButton onClick={this.handleLoginClick}
}
return (
div
Greeting isLoggedIn={isLoggedIn}
{button}
div
);
}
上面是react官网上面的一段代码,通过点击按钮触发事件调用this.setState(),我在控制器看常量isLoggedIn 的输出是改变的,不是说const定义的常量是不可改变的吗?