Basically, I am trying to route a user based on whether or not the page exists. So I tried to do an if statement to check the prop profileExists. If it is true, it would stay on the same page. Otherwise, it would reroute the user away to another route, which is the /homepage route. I was wondering if this is an ok thing to do in React or not. Please see code below:
renderWithRoot(component) {
const { classes, profileExists, history } = this.props;
if (profileExists === false) {
history.push('/homepage');
}
return (
<div className={classes.root}>
{component}
</div>
);
}