rooks
Version:
Collection of awesome react hooks
18 lines (17 loc) • 657 B
TypeScript
import type { Dispatch, SetStateAction } from "react";
type UseSessionstorateStateReturnValue<S> = [
S,
Dispatch<SetStateAction<S>>,
() => void
];
/**
* useSessionstorageState hook
* Tracks a value within sessionStorage and updates it
*
* @param {string} key - Key of the sessionStorage object
* @param {any} initialState - Default initial value
* @returns {[any, Dispatch<SetStateAction<any>>, () => void]}
* @see https://rooks.vercel.app/docs/hooks/useSessionstorageState
*/
declare function useSessionstorageState<S>(key: string, initialState?: S | (() => S)): UseSessionstorateStateReturnValue<S>;
export { useSessionstorageState };