Questions tagged [normalizr]

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.

Useful Links

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…
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),…
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' }, { …
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 ?
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…
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: { …
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…
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", …
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…
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:…
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…
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", …
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…
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…
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…
Matt Wills
  • 536
  • 3
  • 10
1
2 3
15 16