3 ms·
Not using deep equality allows for huge performance gains. You can use an immutability library like https://github.com/guigrpa/timm https://github.com/guigrpa/t
by JMTQp8lwXL 7y ago
Not using deep equality allows for huge performance gains. You can use an immutability library like https://github.com/guigrpa/timm https://github.com/guigrpa/timm to handle mutations, if you want to edit a nested property on an object and return a new object.
- Ineentho 7y agoI haven't heard about timm before, but it looks very similar to immer https://github.com/immerjs/immer https://github.com/immerjs/immer, which is even recommended in the official React docs now
- acemarke 7y agoWe also recommend using Immer with Redux [0], and it's used internally in our new Redux Toolkit package [1]. [0] https://redux.js.org/style-guide/style-guide#use-immer-for-writing-immutable-updates https://redux.js.org/style-guide/style-guide#use-immer-for-w... [1] https://redux-toolkit.js.org/ https://redux-toolkit.js.org/
- tekkk 7y agoNice, thanks to both of you for the tip. I always hated ImmutableJS's clunky API which is partly the reason why I switched from Redux to Mobx as the object assigning felt otherwise so icky. I have to check out if Immer is any better =).