mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-09 04:35:25 +03:00
Add typing
This commit is contained in:
parent
a66b96345b
commit
cf5cbbc7fd
@ -64,12 +64,15 @@ export function usePersistedOverlayState<S extends string>(
|
||||
];
|
||||
}
|
||||
|
||||
export function useHashState(): [string | undefined, (value: string) => void] {
|
||||
export function useHashState<S extends string>(): [
|
||||
S | undefined,
|
||||
(value: S) => void,
|
||||
] {
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const setHash = useCallback(
|
||||
(value: string | undefined) => {
|
||||
(value: S | undefined) => {
|
||||
if (!value) {
|
||||
navigate(location.pathname);
|
||||
} else {
|
||||
@ -81,7 +84,10 @@ export function useHashState(): [string | undefined, (value: string) => void] {
|
||||
[location, navigate],
|
||||
);
|
||||
|
||||
const hash = useMemo(() => location.hash.substring(1), [location.hash]);
|
||||
const hash = useMemo(
|
||||
() => location.hash.substring(1) as unknown as S,
|
||||
[location.hash],
|
||||
);
|
||||
|
||||
return [hash, setHash];
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user