react-router#MemoryRouterProps TypeScript Examples
The following examples show how to use
react-router#MemoryRouterProps.
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: test.moun.helper.tsx From frontend with Apache License 2.0 | 6 votes |
mountVrtComponent = ({
component,
memoryRouterProps = {
initialEntries: ["/"],
},
path = "/",
}: {
component: React.ReactElement;
memoryRouterProps?: MemoryRouterProps;
path?: string;
}) =>
mount(
<MemoryRouter {...memoryRouterProps}>
<Routes>
<Route
path={path}
element={
<SnackbarProvider>
<UserProvider>
<ProjectProvider>
<BuildProvider>
<HelpProvider>
<TestRunProvider>{component}</TestRunProvider>
</HelpProvider>
</BuildProvider>
</ProjectProvider>
</UserProvider>
</SnackbarProvider>
}
/>
</Routes>
</MemoryRouter>,
{
cssFiles: ["src/index.css"],
}
)
Example #2
Source File: DebuggingMemoryRouter.ts From json-schema-viewer with Apache License 2.0 | 6 votes |
constructor(props: MemoryRouterProps) {
super(props);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(this as any).history.listen((location: any, action: any) => { // tslint:disable-line:no-any
console.log(
`The current URL is ${location.pathname}${location.search}${location.hash}`
);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
console.log(`The last navigation action was ${action}`, JSON.stringify((this as any).history, null, 2));
});
}