shadcn-ahooks

useMap

A hook that can manage the state of Map.

Overview

A hook that can manage the state of Map.

Documentation and Examples

Installation

Open in
pnpm dlx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useMap.json
npx shadcn@latest add https://shadcn-ahooks.vercel.app/r/useMap.json
yarn shadcn@latest add https://shadcn-ahooks.vercel.app/r/useMap.json
bun shadcn@latest add https://shadcn-ahooks.vercel.app/r/useMap.json

A hook that can manage the state of Map.

Examples

Default usage

API

const [
  map,
  {
    set,
    setAll,
    remove,
    reset,
    get
  }
] = useMap<K, V>(initialValue);

Result

| Property | Description | Type | | -- | | | - | | initialValue | Optional, set default value | Iterable<[K, V]> | - |

On this page