From 1ab9ad9fcc2dd0bdc9bf868e28bb290df7a19585 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 5 Jan 2022 17:06:36 +0100 Subject: [PATCH] fix the issue where mdx links to a hash were broken --- lib/router/src/router.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/router/src/router.tsx b/lib/router/src/router.tsx index d6cf9bcc8aa1..4c2a753781fc 100644 --- a/lib/router/src/router.tsx +++ b/lib/router/src/router.tsx @@ -61,6 +61,10 @@ const useQueryNavigate = () => { const navigate = useNavigate(); return useCallback((to: string | number, options?: ExpandedNavigateOptions) => { + if (typeof to === 'string' && to.startsWith('#')) { + document.location.hash = to; + return undefined; + } if (typeof to === 'string') { const target = options?.plain ? to : `?path=${to}`; return navigate(target, options);