rooks
Version:
Collection of awesome react hooks
22 lines (21 loc) • 590 B
TypeScript
/**
* useMapState hook
* A hook to manage state in the form of a map or object.
*
* @param initialValue Initial value of the map
* @see https://rooks.vercel.app/docs/hooks/useMapState
*/
declare function useMapState<T extends {
[key: string]: unknown;
}, K extends keyof T>(initialValue: T): [
T,
{
has: (key: K) => boolean;
remove: (key: K) => void;
removeAll: () => void;
removeMultiple: (...keys: K[]) => void;
set: (key: K, value: T[K]) => void;
setMultiple: (next: Partial<T>) => void;
}
];
export { useMapState };