Skip to content
On this page

useMap

A hook that can manage the state of Map.

Code demonstration

API

const [
  map,
  {
    set,
    setAll,
    remove,
    reset,
    get
  }
] = useMap(initialValue?: Iterable<[any, any]>);
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

SourceDocsDemo