MCPcopy
hub / github.com/TanStack/router / RouterContainer

Function RouterContainer

packages/react-router/tests/link.test.tsx:94–117  ·  view source on GitHub ↗
({ children }: { children: React.ReactNode })

Source from the content-addressed store, hash-verified

92 return <h1 data-testid="testId">{children}</h1>
93 }
94 const RouterContainer = ({ children }: { children: React.ReactNode }) => {
95 const childrenRef = React.useRef(children)
96 const memoedRouteTree = React.useMemo(() => {
97 const rootRoute = createRootRoute()
98 const indexRoute = createRoute({
99 getParentRoute: () => rootRoute,
100 path: '/',
101 component: () => (
102 <IndexComponent>{childrenRef.current}</IndexComponent>
103 ),
104 })
105 return rootRoute.addChildren([indexRoute])
106 }, [])
107
108 const memoedRouter = React.useMemo(() => {
109 const router = createRouter({
110 routeTree: memoedRouteTree,
111 history,
112 })
113
114 return router
115 }, [memoedRouteTree])
116 return <RouterProvider router={memoedRouter} />
117 }
118
119 const { result, rerender } = renderHook(
120 () => {

Callers

nothing calls this directly

Calls 3

createRootRouteFunction · 0.90
createRouteFunction · 0.90
createRouterFunction · 0.90

Tested by

no test coverage detected