Normalizr is a tool that normalizes deeply nested JSON API responses according to a schema for Flux and Redux apps. Use this tag for questions regarding the usage, structure, and creation of normalized objects made with normalizr.
Questions tagged [normalizr]
222 questions
43
votes
5 answers
How do you add/remove to a redux store generated with normalizr?
Looking the examples from the README:
Given the "bad" structure:
[{
id: 1,
title: 'Some Article',
author: {
id: 1,
name: 'Dan'
}
}, {
id: 2,
title: 'Other Article',
author: {
id: 1,
name: 'Dan'
}
}]
It's extremely…

m0meni
- 16,006
- 16
- 82
- 141
17
votes
2 answers
How to define schema for recursive model with Normalizr
Having a bit of an issue trying to normalise a payload, that contains a nested schema of the same type as the parent using Normalizr
For example I have the initial object (menu) which has a child (sections) which is an array of objects (section),…

tutts
- 2,373
- 2
- 20
- 24
16
votes
2 answers
Why should I keep the state flat
I'm using ReactJs with Redux and on some tutorials and codes I see people suggesting and using normalizr to keep the state flat. But what is the real advantage in keeping it flat ? Will I encounter any problems if I don't ? Is it necessary ?

Mani Shooshtari
- 760
- 1
- 6
- 19
13
votes
2 answers
Normalizr - How to generate slug/id related to parent entity
How can I assign id/slug related to the entity's parent using normalizr?
Example:
API Response for a user call:
{
id: '12345',
firstName: 'John',
images: [
{
url: 'https://www.domain.com/image0',
name: 'image0'
},
{
…

Aris Goudouras
- 325
- 2
- 7
11
votes
1 answer
Removing items from normalized redux store
Please see this question first here. I am using this sample object that everyone has been using.
{
entities: {
plans: {
1: {title: 'A', exercises: [1, 2, 3]},
2: {title: 'B', exercises: [5, 6]}
},
exercises: {
…

tito
- 149
- 3
- 10
11
votes
3 answers
Redux + Normalizr detached (deleted) operation
I use redux with normalizr to normalize the response from server, basically follow the real-world example. This way entities reducer is very simple, just merge the response. The problem I have right now is kind of delete operation. I've found this…

Jeff.A
- 191
- 1
- 6
10
votes
2 answers
How to reduce renders using redux + normalizr
I have an app using React + Redux + Normalizr, I would like to know the best practices to reduce the number of renders when something changes on entities.
Right if I change just one entity inside the entities, it will re-render all the components…

Sibelius Seraphini
- 5,303
- 9
- 34
- 55
9
votes
1 answer
Why is an array of all `ids` needed in a normalized state shape?
comments : {
byId : {
"comment1" : {
id : "comment1",
author : "user2",
comment : ".....",
},
"comment2" : {
id : "comment2",
author : "user3",
…

nolawi
- 4,439
- 6
- 22
- 45
8
votes
2 answers
TypeScript: How to create an interface for an object with many keys of the same type and values of the same type?
I'm building a React Native app in TypeScript with Redux and Normalizr. So I will have noramlized state.
I have four interfaces: Emotion, Need, PainData and PainReport:
export interface Emotion {
name: string;
chosen: boolean;
rating:…

J. Hesters
- 13,117
- 31
- 133
- 249
8
votes
1 answer
Redux State Shape for One-to-Many Relationships
When designing a state shape with related entities, the official Redux docs recommend referencing by ID rather than nesting: http://redux.js.org/docs/basics/Reducers.html#note-on-relationships.
In a one-to-many relationship, Normalizr will put the…

miljinx
- 97
- 1
- 7
8
votes
2 answers
Redux normalizr - nested API responses
How can I use normalizr to deal with nested standardised JSON API responses that are key via the { data: ... } standard?
For example a Book
{
data: {
title: 'Lord of the Rings',
pages: 9250,
publisher: {
data:…

AndrewMcLagan
- 13,459
- 23
- 91
- 158
7
votes
2 answers
Redux normalizr + dealing with reduced responses
Normalizr is great at creating structured JSON repositories of entities.
We have many cases displaying lists of data e.g. posts that have been normalised. Where posts are listed the API response is limited to a few key fields.
We also have cases…

AndrewMcLagan
- 13,459
- 23
- 91
- 158
6
votes
1 answer
denormalise reverse processStrategy
I have an API that gives out data like this with the attributes in a fields property.
{
records: [
{
id: "123",
fields: {
author: {
id: "1",
name: "Paul"
},
title: "My awesome blog post",
…

jorisjh
- 136
- 7
6
votes
1 answer
Normalizr: Identifying entities by type rather than schema for polymorphic mappings
For a polymorphic schema such as Union in Normalizr, for schema definitions and data:
const data = { owner: { id: 1, type: 'user', name: 'Anne' } };
const user = new schema.Entity('users');
const group = new schema.Entity('groups');
const…

Karptonite
- 1,490
- 2
- 14
- 30
6
votes
1 answer
How to merge updates into normalized redux state
I just start using normalizr to manage my state. I've gotten to the point where the below code updates the needed objects but I haven't been able to merge them back into the normalized state in a clean, dry way. What is the preferred way of doing…

user7359628
- 61
- 2