The Redirect component in React-router does exactly what it sounds like. It allows us to redirect from the one route to another.
Import React from ' React 'Import {hashhistory, Route, Redirect, Router, Link} from' React-router '; Const Home= () = <div>Const Links= () = <nav > <link activestyle={{color: ' Green '}} to= "/" >Home</Link> <link acti Vestyle={{color: ' Green '} to= "/about-us" >About-us</Link> <link activestyle={{color: ' Green '}} to= "/abo UT ">About</Link> <link activeclassname=" active "to="/contact ">Contact</Link> </nav>;class App extends React.component {render () {return( <router history={hashhistory}> <route path= "/" Component={home}></route> & Lt Route path= "/about-us" component={aboutus}></route> <route path= "/contact" component={contact}& Gt;</route><redirect from = "*" to = "/about-us" ></Redirect></Router> ); }}exportdefaultAPP;
[React] React Router:redirect