unadlib / mutative

Efficient immutable updates, 2-6x faster than naive handcrafted reducer, and more than 10x faster than Immer.
http://mutative.js.org/
MIT License
1.53k stars 16 forks source link

Filter does not work correctly when array contains objects #20

Closed Gongreg closed 7 months ago

Gongreg commented 7 months ago

Hello. Thank you for quick replies on previous issues! We've noticed one more issue:

import { create } from 'mutative';

const baseState = {
  array: [
    {x: 1}
   ]
};

const state = create(baseState, (draft) => {
  draft.array = draft.array.filter(o => o.x !== 1)
}); 

console.log(state.array) // expected [], received [undefined]

This issue seems to happen if filtering is done on array that has objects inside, if it has numbers in it works correctly.

unadlib commented 7 months ago

hi @Gongreg ,

I just realized that too. I've fixed it, v0.7.1 has been released.

Gongreg commented 7 months ago

Wow, blazing fast!

Confirmed that the issue is fixed.