pmndrs / zustand

🐻 Bear necessities for state management in React

Home Page:https://zustand-demo.pmnd.rs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Immer Middelware Typescript error: Exported variable 'useMyStore' has or is using name 'WritableDraft' from external module "../node_modules/immer/dist/immer" but cannot be named.

rohitspujari opened this issue · comments

When I add an array property of a custom type like Cites: City[], the build fails with the error above. But if I use City: any[], or a singular property like string or even a singular custom type city: City, it works fine.

Here is how I configured my store

export const useMyStore = create<MyStore>()( immer((set, get) => ({ ... }))
I'm using Vite for the build.