In my component I want to check if a user is logged and if not, then redirect to the login page. Currently I do the check and redirect in componentWillMount.
public componentWillMount() {
if(this.props.master === null) {
this.props.history.push('./login');
}
}
However even though the redirect does occur both render() and componentDidMount() are still run, which crashes my code because in there I assume master is not null.