Redux & Redux Toolkit
/Advanced
Normalized State
Definition
A database-like state structure where each item is stored uniquely under its ID in a dictionary object, and arrays of IDs are used to indicate ordering.
Explain Like I'm New
Deeply nested arrays are a nightmare to update in Redux. If you want to update Comment 4 on Post 3 by User 2, writing the immutable spread operators is horrific. Normalization flattens everything. You just do `state.comments['comment4'].text = 'New Text'`.
Real World Example
Using `createEntityAdapter` to automatically normalize incoming array data from an API into a dictionary of `{ ids: [], entities: {} }`.
Common Use Cases
- •Managing relational data
- •Instant O(1) item lookups
Interactive Example
Loading...
Console output will appear here...
Interview Questions
basic
- What two keys are typically present in a normalized state slice?
intermediate
- Why does normalizing data improve React rendering performance?