Skip to content

Latest commit

 

History

History
23 lines (20 loc) · 463 Bytes

File metadata and controls

23 lines (20 loc) · 463 Bytes

useWeakSet

WeakSet hook

function useWeakSet<T extends object>(
  initValue?: Iterable<T>,
): [
  state: WeakSet<T>,
  action: {
    readonly add: (value: T) => void;
    readonly clear: () => void;
    readonly has: (value: T) => boolean;
    readonly remove: (value: T) => boolean;
    readonly reset: () => void;
    readonly addAll: (val: Iterable<T>) => void;
  },
];
const [, { add, addAll, has }] = useWeakSet(['a', 'b', 'c']);