I have a logout button and when it's clicked nothing changes, even though there is a function call that does setState({isLoggedIn: false})
I do have a componentWillMount()
function to set it in the first place to what the props is because it wasn't changing to being true when I was set in the parent.
How do I fix this as react throws no errors. I have been looking at this for a good hour now with no avail.
some code
onLogOutClick(){
this.setState({
isLoggedIn: false,
)}
}
componentWillMount(){
this.setState({
isLoggedIn: this.props.IsLoggedIn
}, function(){
});
}
...
{this.props.IsLoggedIn ? (
<ul className="nav navbar-nav navbar-right">
<li>
<button
onClick={() => this.onLogOutClick()}
className="form-control"
style={{
marginTop: "10px",
color: "black",
border: "none"
}}
>
<span className="glyphicon glyphicon-log-out"/>
LogOut {this.state.Username}
</button>
</li>
</ul>
) : "LOGGED OUT"
}
that changes from logged out to the button when logged in but doesnt work the other way around