@reach/router#createHistory TypeScript Examples
The following examples show how to use
@reach/router#createHistory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From hubble-ui with Apache License 2.0 | 6 votes |
constructor(historySource: RouteHistorySourceKind, routes?: Route[]) {
this.routes = routes || [];
this.history =
historySource === 'url'
? globalHistory
: createHistory(createMemorySource('/'));
this.location = this.history.location;
this.listen();
}
Example #2
Source File: test.tsx From baleen3 with Apache License 2.0 | 6 votes |
export function renderWithRouter(
ui: Readonly<React.ReactElement>,
route = '/',
options?: Omit<RenderOptions, 'queries'>,
delegate = renderLight
): RenderResult & { history: History } {
const history = createHistory(createMemorySource(route))
return {
...delegate(
<LocationProvider history={history}>{ui}</LocationProvider>,
options
),
history,
}
}