Skip to content

useMap ​

A hook that can manage the state of Map.

Code demonstration ​

API ​

typescript
const [
  map,
  {
    set,
    setAll,
    remove,
    reset,
    get
  }
] = useMap(initialValue?: Iterable<[any, any]>);

Result ​

PropertyDescriptionType
mapMap objectReadonly<Ref<Map>>
setAdd item(key: any, value: any) => void
getGet item(key: any) => MapItem
setAllSet a new Map(newMap: Iterable<[any, any]>) => void
removeRemove key(key: any) => void
resetReset to default() => void
clearclear Map() => void

Params ​

PropertyDescriptionTypeDefault
initialValueOptional, set default valueIterable<[any, any]>-

Source ​

Source · Document · Demo

Released under the MIT License.