Every line of 'react router get current route' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
81 currentRoute() { 82 return this._currentRoute; 83 }
53 getCurrentRoute() { 54 let routeList = _navigator.getCurrentRoutes(); 55 let currentRoute = routeList[routeList.length - 1]; 56 return currentRoute; 57 }
53 get currentRoute():Route { 54 return this.routes[this._stack[this._stack.length-1]]; 55 }
532 public static getCurrentRoute():RouterEvent { 533 return this._currentRoute; 534 }
622 public static getCurrentRoute():RouterEvent 623 { 624 return this._currentRoute; 625 }
12 getCurrentRoute () { 13 const { hash } = window.location 14 return hash ? hash.split('#')[1] : this.defaultRoute 15 }
175 currentRoute () { 176 const routeData = Matcher.matchPath(this.routes, this.currentPath()) 177 if (routeData) { 178 return routeData 179 } else { 180 return null 181 } 182 }
27 get currentRoute(): any { 28 return this._currentRoute; 29 }
38 public get currentRoute() { 39 return this._currentRoute; 40 }
9 export default function Router() { 10 const [current, setCurrent] = useState('home') 11 useEffect(() => { 12 setRoute() 13 window.addEventListener('hashchange', setRoute) 14 return () => window.removeEventListener('hashchange', setRoute) 15 }, []) 16 function setRoute() { 17 const location = window.location.href.split('/') 18 const pathname = location[location.length-1] 19 console.log('pathname: ', pathname) 20 setCurrent(pathname ? pathname : 'home') 21 } 22 return ( 23 24 <nav> 25 26 27 28 29 30 31 </nav> 32 ) 33 }