Import React, {proptypes} from ' React 'Import Reactdom from' React-dom 'Import {hashrouter, Route, Link, Redirect, withrouter} from' React-router-dom 'Const Home= ({history}) = = { return( <div> )}const One= ({history}) = = { return( <div> )}const Zlink= ({to,val,isexact}) = = { return( <route path={to} exact={isexact} children={({match}) ={Console.log (match,to.tostring ())return( <div>{Match? ' > ': '}<link to={to}>{val}</link> </div> ) }} />//When you need to edit the navigation based on the current URL, you can package a route label outside of link //The current URL information is obtained through the match of the function parameter under the Children property)}exportdefaultclass App extends React.component {constructor (props) {super (props); } render () {return( <HashRouter> <div> <ul> <zlink to= "/" val= "Home" isexact={true}/> <zlink to= "/one" val= "first page" isexact={true}/> </ul> <route exact path= "/" component={home}/> <route path= "/one" Compon Ent={one}/> </div> </HashRouter>)}}reactdom.render (<app/>,document.getelementbyid ("App"))
React-router 4.0 (iii) show navigation based on current URL