Skip to content

useMap

Category
Export Size
252 B
Last Changed
5 days ago

A real Map whose mutations re-render.

Demo

Usage

tsx
import { 
useMap
} from '@reause/shared'
const
map
=
useMap
([['a', 1]])
map
.
set
('b', 2) // re-renders; returns the same Map
map
.
get
('b') // 2
map
.
size
// 2
map
.
delete
('a') // re-renders; returns true
map
.
clear
() // re-renders; returns undefined

Type Declarations

ts
export function useMap<K = any, V = any>(entries?: ReadonlyArray<readonly [
    K,
    V
]> | null): Map<K, V>

Source

Source · Demo · react-hookz

Contributors

hairyf

Changelog

v0.1.7 on
e9f8f - feat(shared): add useMap (#932)

Released under the MIT License. v0.1.8