Skip to content

Commit

Permalink
fix(rr6): Avoid recursive import of useNavigate/useRouter (#76747)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Aug 29, 2024
1 parent 2d4a540 commit 4349def
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions static/app/utils/useNavigate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {NODE_ENV} from 'sentry/constants';
import normalizeUrl from 'sentry/utils/url/normalizeUrl';

import {locationDescriptorToTo} from './reactRouter6Compat/location';
import useRouter from './useRouter';
import {useRouteContext} from './useRouteContext';

type NavigateOptions = {
replace?: boolean;
Expand Down Expand Up @@ -48,8 +48,11 @@ export function useNavigate(): ReactRouter3Navigate {
return navigate;
}

// XXX(epurkihser): We are using react-router 3 here, to avoid recursive
// dependencies we just use the useRouteContext instead of useRouter here

// biome-ignore lint/correctness/useHookAtTopLevel: react-router-6 migration
const router = useRouter();
const {router} = useRouteContext();

// biome-ignore lint/correctness/useHookAtTopLevel: react-router-6 migration
const hasMountedRef = useRef(false);
Expand Down

0 comments on commit 4349def

Please sign in to comment.