You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are some examples, such as updating an array (filter out items where the name is not 'Test', and set the 'done' value to true for each of the remaining items):
consttodoList=[{name: 'Test'},{name: 'Learn'},{name: 'Test'}];// This will throw the errorconststate=create(todoList,(draft)=>draft.filter((item)=>{if(item.name==='Test'){item.done=true;returntrue;}}));
We have to write the array update in a similar way.
Regarding return values, Mutative has the same behavior as Immer.
An draft function returned a new value and modified its draft. Either return a new value or modify the draft.
For example,
However, there is an irrational aspect to this approach. As long as a modified draft can be finalized, it should be allowed to return any value.
Therefore, we are considering allowing Mutative to support draft functions returning any value.
The text was updated successfully, but these errors were encountered: