udecode / zustand-x

Zustand store factory for a best-in-class developer experience.

Home Page:https://zustand-x.udecode.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support maps in immer

rafpaz opened this issue · comments

Description

When using es6 Maps inside store, immer throws the following error:
Uncaught Error: [Immer] The plugin for 'MapSet' has not been loaded into Immer. To enable the plugin, import and call enableMapSet() when initializing your application..

On our app, we use immer with zustand, and just adding:

import { enableMapSet } from 'immer';
enableMapSet();

solved it.

Steps

  1. Create a store with a map object, for example:
export const storeWithMap = createStore('storeWithMap')({ tasks: new Map<string, Task>() });
  1. App crashes with the above error

Expectation
Would be really nice if it will be possible to add another property into immer's options object on createStore, for enabling maps usage.

Fixed in: #28