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]
226 questions
39
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…
![](../../users/profiles/3772221.webp)
m0meni
- 14,160
- 14
- 66
- 120
16
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),…
![](../../users/profiles/526808.webp)
tutts
- 2,083
- 1
- 19
- 24
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'
},
{
…
![](../../users/profiles/2059904.webp)
Aris Goudouras
- 315
- 2
- 7
13
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 ?
![](../../users/profiles/5607525.webp)
Mani Shooshtari
- 650
- 1
- 6
- 19
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…
![](../../users/profiles/1828955.webp)
Jeff.A
- 191
- 1
- 6
10
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: {
…
![](../../users/profiles/6714114.webp)
tito
- 139
- 2
- 9
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…
![](../../users/profiles/2628278.webp)
Sibelius Seraphini
- 4,023
- 7
- 30
- 52
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",
…
![](../../users/profiles/2903708.webp)
nolawi
- 3,843
- 5
- 18
- 43
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…
![](../../users/profiles/5733701.webp)
miljinx
- 97
- 1
- 5
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:…
![](../../users/profiles/913622.webp)
AndrewMcLagan
- 11,928
- 19
- 75
- 144
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…
![](../../users/profiles/913622.webp)
AndrewMcLagan
- 11,928
- 19
- 75
- 144
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",
…
![](../../users/profiles/10770300.webp)
jorisjh
- 116
- 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…
![](../../users/profiles/53537.webp)
Karptonite
- 1,577
- 1
- 13
- 27
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…
![](../../users/profiles/7359628.webp)
user7359628
- 61
- 2
5
votes
0 answers
Is it possible to properly memoize reselect selectors when using denormalize?
I recently noticed that when using normalizr’s ‘denormalize’ function within a reselect selector, memoization was failing every time.
This is down to having to pass the entire entities object to the selector as an argument, which i suppose is too…
![](../../users/profiles/7583056.webp)
Matt Wills
- 536
- 3
- 10