fix(stories): let Components Lab load stories that import Navigate (#64229)

This commit is contained in:
usrnk1
2026-11-16 14:55:30 +01:00
committed by GitHub
Unverified
parent 139e5c2a14
commit d8da34d23f
+14
View File
@@ -68,6 +68,20 @@ export function useNavigate() {
}
}
export function Navigate(props: {
href:
| string
| ((args: { navigate: ReturnType<typeof useNavigate>; location: ReturnType<typeof useLocation> }) => string)
state?: unknown
}) {
const navigate = useNavigate()
const path = typeof props.href === "function" ? props.href({ navigate, location: useLocation() }) : props.href
navigate(path, { replace: true, state: props.state })
return null
}
export function useSearchParams<T extends Record<string, string>>() {
const ctx = useContext(RouterContext)