UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

9 lines (8 loc) 251 B
import { useRef } from "react"; /** Create a mutable Map that persist for the lifetime of the component. */ export function useMap() { const ref = useRef(undefined); if (!ref.current) ref.current = new Map(); return ref.current; }