Loading homepage
Implement a real React hook called useMap that manages a JavaScript Map in component state. Provide convenient actions for adding or replacing entries, removing keys, clearing the Map, replacing all entries, and resetting it.
The supplied tests mount React components and verify rerenders, batched updates, and Strict Mode. Both JavaScript and TypeScript variants use the same hook API.
Input: const [map, actions] = useMap([["a", 1]]); // In an event handler: actions.set("b", 2); Output: On the next render: Array.from(map) is [["a", 1], ["b", 2]].
Input: actions.clear(); // After rerender: the Map is empty. actions.reset(); Output: After the reset rerender: the initial entries are restored.
useMap(initialEntries?) returns [map, { set, setAll, remove, clear, reset }]. Actions update state; read the new Map after React rerenders. See usage-examples.md for a complete React component.