Nate May
Nate May

Reputation: 4072

Immutable.js fromJS() is not returning an immutable object

I'm using "immutable": "^3.8.1", in my redux store (ngrx). I know that it's installed because I have successfully converted my stated into an immutable object

const immState = Imm.fromJS(state);

enter image description here

But I hit an issue when I tried to delete a deeply nested item with this command:

return immState.deleteIn(['days', dayKey, 'userMeals', state.focus_user], meal._id);

Immutable.js is throwing an error when it hits 'userMeals' and upon further investigation, it seems that Imm.fromJS() is not converting a deeply nest object into an immutable structure. In the image below I try to access that property directly, but it is still not converting it into an immutable object.

enter image description here

Is this somehow the expected behavior or am I missing something?

Upvotes: 1

Views: 591

Answers (1)

Nate May
Nate May

Reputation: 4072

I found my answer HERE. Apparently ES6 classes give immutable.js issues, surprisingly. there are solutions though.

Upvotes: 1

Related Questions