rich-text-editor
Version:
Rich text editor
16 lines (15 loc) • 529 B
TypeScript
export type MapHookHandle<K, V> = ReturnType<typeof useMap<K, V>>;
/**
* An ES6 `Map` object that's bound to a React state.
*
* Mutations on the returned object will cause a rerender.
*/
export default function useMap<K, V>(initial?: Iterable<[K, V]>): {
/** The underlying Map object. **Mutating this won't cause a rerender!** */
raw: Map<K, V>;
has: (key: K) => boolean;
get: (key: K) => V | undefined;
values: () => MapIterator<V>;
set: (key: K, value: V) => void;
delete: (key: K) => void;
};