use-router
Hooks to work with routes in the browser
Last updated
Was this helpful?
Hooks to work with routes in the browser
Hook to handle routes based on expressions according to the https://github.com/uppercod/exp-route library, this hook is used by @atomico/components/router****
import {
useRouter,
useRoute,
useRouteMatch,
useRedirect,
redirect,
getPath
} from "@atomico/hooks/use-router";const [ view, path, params, search ] = useRouter({
"/":()=><h1>home</h1>,
"user/{id}":({ id })=><my-user id={id}/>,
})Where:
view: return of the last function executed according to the route match.
path: string, represents the prop of the last path that consists of the path match.
params: parameters captured according to the path
search: parameters captured from the path
Share the return from useRouter
Last updated
Was this helpful?
Was this helpful?
const [ view, path, params, search ] = useRoute("/",()=><h1>home</h1>);const match = useRouteMatch();
const isHome = match("/home");