Skip to content

Commit c0753f0

Browse files
authored
fix(react): Warn and fall back gracefully if dependency injected functions are not available (#12026)
1 parent d6cb302 commit c0753f0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

packages/react/src/reactrouterv6.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,15 @@ export function wrapCreateBrowserRouter<
340340
TState extends RouterState = RouterState,
341341
TRouter extends Router<TState> = Router<TState>,
342342
>(createRouterFunction: CreateRouterFunction<TState, TRouter>): CreateRouterFunction<TState, TRouter> {
343+
if (!_useEffect || !_useLocation || !_useNavigationType || !_matchRoutes) {
344+
DEBUG_BUILD &&
345+
logger.warn(
346+
'reactRouterV6Instrumentation was unable to wrap the `createRouter` function because of one or more missing parameters.',
347+
);
348+
349+
return createRouterFunction;
350+
}
351+
343352
// `opts` for createBrowserHistory and createMemoryHistory are different, but also not relevant for us at the moment.
344353
// `basename` is the only option that is relevant for us, and it is the same for all.
345354
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)