UNPKG

@hypothesis/frontend-shared

Version:

Shared components, styles and utilities for Hypothesis projects

16 lines (15 loc) 793 B
/** * Hook that sets up the router for the component library and returns the * current route. * * Clicks on links in the current page to URLs that are under {@link baseURL} * are automatically intercepted and handled. * * @param {string} baseURL - Pathname of the root URL of the application. * @param {PlaygroundRoute[]} routes * @return {[route?: PlaygroundRoute, navigate: (e: Event, url: string) => void]} - * Returns the current route's data and a `navigate` function to manually * trigger a client-side navigation to another route. */ export function useRoute(baseURL: string, routes: PlaygroundRoute[]): [route: import("./routes").PlaygroundRoute | undefined, navigate: (e: Event, url: string) => void]; export type PlaygroundRoute = import('./routes').PlaygroundRoute;