Here is my code in my component:
class MyComp extends React.Component {
  componentDidMount(){
    this._isMounted = true;
    axios.get(URL).
    then(res => {
      if(this._isMounted) {
        if(res=="ok")
          this.props.history.push("en/dashboard");
        }
    })
  }
  componentWillUnmount(){
    this._isMounted = false;
  }
}
My index.js with routes:
<Switch>
  <Route exact path={`${match.url}/`} component={MyComp} />
  <Route path={`${match.url}/dashboard`} component={Dashboard} />
</Switch>
And component renders infinitely when I do the axios call and I do not know how to handle this, I just want a simple redirect to another route. Thank you!
 
     
     
    