In this video we are going to learn about Programmatic Redirects.
History Library main thing in React Router.
When React Router provides components, it will pass three accessory components: location, match, and history.
This history accessory comes from the History library and has several luxury properties relative to the route.
In this case, the most desired is history.push.
What it does is insert new entries into the history stack, i.e. redirect the user to another path.
Alrght now lets see how can we redirect.
So switch to the project.
Now just open the Navbar.js.
Here first of all inport withRouter.


import {withRouter} from 'react-router-dom';


Add setTimout inside the render method.


 render(){
      setTimeout(()=>{
        this.props.history.push('/contact');
      },3000);
}



It will auto redirect to contact component after 3 seconds ok.
So lets check So switch to browser and click on home.
Now it will redirect after 3 second on contact component.
Let see so just click on home.
This is home component.
You can see its auto redirect after 3 seconds on contact page.
So in this way you can programatically redirect in react.