Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

client.tsx

29 lines891 Bytes

1import { RouterProvider } from '@tanstack/react-router'
2import { isServer } from '@tanstack/router-core/isServer'
3import { createRoot } from 'react-dom/client'
4import { assertStateUpdates, createLinkRouter } from './workload'
5import type { LinkRouter } from './workload'
6import type { RouterHistory } from '@tanstack/history'
7import type { LinkCaseId } from '../cases'
8​
9export const serverEnvironment: boolean | undefined = isServer
10​
11export function mountTestApp(
12 container: HTMLElement,
13 history: RouterHistory,
14 caseId: LinkCaseId,
15): {
16 router: LinkRouter
17 unmount: () => void
18 assertStateUpdates: () => void
19} {
20 const router = createLinkRouter(caseId, history, false)
21 const root = createRoot(container)
22 root.render(<RouterProvider router={router} />)
23​
24 return {
25 router,
26 unmount: () => root.unmount(),
27 assertStateUpdates: () => assertStateUpdates(router),
28 }