useMap
Map state with immutable set, replace, remove, clear and reset actions.
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
Examples
Playground
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.
Related
MapAn interactive geographic map with selectable markers, route lines, and camera controls. Powered by MapLibre; applications supply their own style, geography, and prepared data.useLocalStorageuseState persisted to localStorage, synced across components and tabs.useReadLocalStorageRead-only localStorage subscriptions shared with useLocalStorage.useSelectionMulti-select state in a Set, with select-all and indeterminate support.useSessionStorageuseState persisted to sessionStorage for one tab.