Normalizing the Data
Discover how to normalize nested API data in Redux using the normalizr library. Learn to define schemas and transform complex JSON into a flat structure, enabling straightforward updates to your Redux store and simpler reducer code.
We'll cover the following...
We'll cover the following...
With the reducers updated and the action structure defined, we are left to extract the payload from the denormalized data we got from the server.
A simple approach might have a custom function that knows each API’s shape and normalizes the returned nested JSON into a flat structure with custom code.
Since this is quite a common practice, the normalizr library can replace custom code. We can define the schema of the data coming from the server and have the normalizr ...