- Notifications
You must be signed in to change notification settings - Fork0
A Mutative middleware for Zustand enhances the efficiency of immutable state updates.
License
mutativejs/zustand-mutative
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
AMutative middleware for Zustand enhances the efficiency of immutable state updates.
With the Mutative middleware, you can simplify the handling of immutable data in Zustand in a mutable way, allowing you to use immutable state more conveniently.
zustand-mutative is 2-6x faster than zustand with spread operation, more than 10x faster thanzustand/middleware/immer.Read more about the performance comparison in Mutative.
In order to use the Mutative middleware in Zustand, you will need to install Mutative and Zustand as a direct dependency.
npm install zustand-mutative zustand mutative# Or use any package manager of your choice.import{create}from'zustand';import{mutative}from'zustand-mutative';typeState={count:number;};typeActions={increment:(qty:number)=>void;decrement:(qty:number)=>void;};exportconstuseCountStore=create<State&Actions>()(mutative((set)=>({count:0,increment:(qty:number)=>set((state)=>{state.count+=qty;}),decrement:(qty:number)=>set((state)=>{state.count-=qty;}),})));
zustand-mutative is inspired byzustand/middleware/immer.
zustand-mutative isMIT licensed.
About
A Mutative middleware for Zustand enhances the efficiency of immutable state updates.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.