Skip to content
GaudiGaudi Design System home

Search documentation

Search every page, heading and paragraph.

useMap

Map state with immutable set, replace, remove, clear and reset actions.

HooksData@gaudi/design-system/hooks/data/use-mapView in StorybookSource

Accepts a Map or iterable of key-value pairs. Each mutation creates a new Map, preserving caller-owned input. The initial entries are snapshotted once, including single-use iterators; reset copies that snapshot.

Usage

import { useMap } from '@gaudi/design-system/hooks';
const [drafts, { set, remove, reset }] = useMap([['intro', 'Draft']]);

Examples

Playground

Storybook

API

1 option
2 return values

Accessibility

Render stable keys and keep focus meaningful when entries are removed.

Notes

  • Do not call map.set/delete/clear directly; those mutations cannot notify React.