Re:React Common Tools and Practices: State Management Overview
by nawgz on Monday March 08, 2021 @11:59AM
(#26388068)
Yes, absolutely that is my understanding of immutability. It's why I asked the performance question, but Immer docs are convincing, I see your point.
Not a surprise to me that mwestrate is the author after seeing the description of Immer - he has an excellent graph knowledge and applies clever architectures & optimizations from that.
I recognize it's completely different from how MobX works, I simply mean to say that I feel MobX is superior and this mere idea of mutability / copying instead of smartly updating a graph and correspondingly only the observer portions of your UI seems like the core of that
However, that process is very tedious and error-prone due to writing lots of nested spread operations.
Immer effectively does those same steps, but automatically. This is all completely different than how Mobx works.
Immer has a slight performance overhead [1], but in practice reducer logic is almost never a meaningful perf bottleneck in a React+Redux app - the cost of updating the UI is might higher.
It's also worth noting that Immer was actually created by Michel Weststrate, the author of Mobx :)
[0] https://redux-toolkit.js.org/usage/immer-reducers#basics-of-...
[1] https://immerjs.github.io/immer/docs/performance