Prevent crash trying to access nullish location state (#39408)

This commit is contained in:
diondiondion authored and Claire committed 2026-06-15 17:01:10 +02:00
1 parent 6cf9be9880
commit fcf222246a
1 file changed
+4 -6
@@ -55,13 +55,11 @@ export const FocusTargetProvider: React.FC<{
| null
>(null);
const {
pathname,
search,
state = {},
} = useLocation<{ focusTarget?: FocusTarget } | undefined>();
const { pathname, search, state } = useLocation<{
focusTarget?: FocusTarget;
} | null>();
const { focusTarget } = state;
const { focusTarget } = state ?? {};
useLayoutEffect(() => {
// We never want to set focus on page load, so we keep