I have a problem with reducer created by immer.js in TypeScript.
I don't understand the following:
When I use an object literal {} in initial state immutability works fine but once
const byId = (state = {}, action) =>
produce(state, draft => {
switch (action.type) {
case RECEIVE_PRODUCTS:
...
)
}
})
I change literal to instance of object immutability stop works
const byId = (state = new SomeObject(), action) =>
produce(state, draft => {
switch (action.type) {
case RECEIVE_PRODUCTS:
...
)
}
})
Can you someone idea why?
Thanks..