mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-20 18:57:17 +03:00
fix(stories): let Components Lab load stories that import Navigate (#64229)
This commit is contained in:
committed by
GitHub
Unverified
parent
139e5c2a14
commit
d8da34d23f
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user