UNPKG

rooks

Version:

Essential React custom hooks ⚓ to super charge your components!

26 lines 1.05 kB
declare type Add<T> = (...args: Parameters<Set<T>["add"]>) => void; declare type Delete<T> = (...args: Parameters<Set<T>["delete"]>) => void; export declare type UseSetStateControls<T> = { add: Add<T>; delete: Delete<T>; clear: () => void; }; export declare type UseSetStateReturnValue<T> = [Set<T>, UseSetStateControls<T>]; /** * useSetState * @description Manage the state of a Set in React. * @param {Set<T>} initialSetValue The initial value of the set to manage. * @returns {UseSetStateReturnValue<T>} The state of the Set and the controls. * @see {@link https://react-hooks.org/docs/useSetState} * @example * import { useSetState } from "@/hooks/useSetState"; * const [set, setControls] = useSetState(new Set()); * setControls.add(1); // {1} * setControls.add(2); // {1, 2} * setControls.delete(1); // {2} * setControls.clear(); // {} * */ declare function useSetState<T>(initialSetValue: Set<T>): UseSetStateReturnValue<T>; export { useSetState }; //# sourceMappingURL=useSetState.d.ts.map