MCPcopy
hub / github.com/getsentry/sentry / createRoutesFromConfig

Function createRoutesFromConfig

tests/js/sentry-test/reactTestingLibrary.tsx:156–197  ·  view source on GitHub ↗
(
  children: React.ReactNode,
  config: RouterConfig | undefined
)

Source from the content-addressed store, hash-verified

154}
155
156function createRoutesFromConfig(
157 children: React.ReactNode,
158 config: RouterConfig | undefined
159): RouteObject[] {
160 // By default react-router 6 catches exceptions and displays the stack
161 // trace. For tests we want them to bubble out
162 function ErrorBoundary(): React.ReactNode {
163 throw useRouteError();
164 }
165
166 const emptyRoute = {
167 path: '*',
168 element: <div>No routes match, check that your location matches your route</div>,
169 errorElement: <ErrorBoundary />,
170 };
171
172 if (config?.route) {
173 return [
174 {
175 path: config.route,
176 element: children,
177 errorElement: <ErrorBoundary />,
178 children: config.children,
179 },
180 emptyRoute,
181 ];
182 }
183
184 if (config?.routes) {
185 return [
186 ...config.routes.map(route => ({
187 path: route,
188 element: children,
189 errorElement: <ErrorBoundary />,
190 children: config.children,
191 })),
192 emptyRoute,
193 ];
194 }
195
196 return [{path: '*', element: children, errorElement: <ErrorBoundary />}];
197}
198
199function makeRouter({
200 children,

Callers 1

makeRouterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected