diff --git a/src/useMap.ts b/src/useMap.ts index 749ac656e9..ae1ffa9658 100644 --- a/src/useMap.ts +++ b/src/useMap.ts @@ -15,10 +15,10 @@ const useMap = (initialMap: T = {} as T): [T, Actions { get: (key: keyof T) => map[key as string], set: (key: K, entry: T[K]) => { - set({ - ...map, + set((prevMap)=>({ + ...prevMap, [key]: entry, - }); + })); }, remove: (key: keyof T) => { const { [key]: omit, ...rest } = map;