useMap

Custom hook that manages a key-value [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) state with setter actions.

Custom hook that manages a key-value Map state with setter actions.

Usage

import { useMap } from "@tilt-legal/cubitt-components/utilities/hooks";

const [map, mapActions] = useMap();
// Access the `map` state and use `mapActions` to set, remove, or reset entries.

API

Signature

declare function useMap<K, V>(initialState?: MapOrEntries<K, V>): UseMapReturn<K, V>;

Parameters

ParameterTypeDescriptionDefault
[initialState]MapOrEntries&lt;K, V&gt;The initial state of the map as a Map or an array of key-value pairs (optional).-

Return Value

ValueTypeDescription
returnUseMapReturn&lt;K, V&gt;A tuple containing the map state and actions to interact with the map.

On this page