UNPKG

foxact

Version:

React Hooks/Utils done right. For browser, SSR, and React Server Components.

17 lines (15 loc) 764 B
type NotUndefined<T> = T extends undefined ? never : T; type Serializer<T> = (value: T) => string; type Deserializer<T> = (value: string) => T; interface UseUrlHashStateRawOption { raw: true; } interface UseUrlHashStateParserOption<T> { raw?: false; serializer: Serializer<T>; deserializer: Deserializer<T>; } /** @see https://foxact.skk.moe/use-url-hash-state */ declare function useUrlHashState<T>(key: string, defaultValue?: NotUndefined<T>, options?: UseUrlHashStateRawOption | UseUrlHashStateParserOption<T>): readonly [NonNullable<T> | null, (v: React.SetStateAction<T | null>) => void]; export { useUrlHashState as unstable_useUrlHashState }; export type { Deserializer, Serializer, UseUrlHashStateParserOption, UseUrlHashStateRawOption };