I have used immer in the past and really enjoyed it. It makes using redux a breeze. I recently found out about normlizr and it looks great as well.
What is the difference between the two? Does immer provide the same normalized solution as normalizr? What is the better choice out of the two for a production app? Or should they be used together?
They're two completely different tools, and may be used together.
Immer is a library for performing immutable updates to data while writing "mutating" syntax.
Normalizr is a library for taking nested data of multiple types (such as a Post
that contains a User
and Comments
), and extracting them all to a set of normalized lookup tables.
Both of them are commonly used in Redux apps.
Our official Redux Toolkit package already has Immer built-in. RTK also comes with a createEntityAdapter
API for storing and updating normalized data, which uses Immer internally, and we specifically have a usage guide section on pre-processing response data with Normalizr and then handling it with createEntityAdapter