You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my first App with Redux, I am trying to keep my collections normalised as recommended. This way you only have to change the Entities in one place. (this feels right to me)
At first i successfully normalised my Array of data to an Array-like-Object of Entities with the id's as key's
Then i wanted to list the entities in a View, so i had to parse it back to an Array. Also if i want to filter my Entities, i need the real Array. Is this really the right approach?
Example with re-select:
// As "id" for my images i use "uri"imageEntities={uri1: {image...},uri2: {image...},
....}// Selectors:constimagesSelector=state=>state.images;// parse the Array-like-Object to an ArrayconstimagesArySelector=createSelector([imagesSelector],images=>{letary=[];for(varkeyinimages){if(images.hasOwnProperty(key)){ary.push(images[key]);}}returnary;});// filter the Array to get only the new imagesexportconstnewImagesSelector=createSelector([imagesArySelector],images=>images.filter(image=>image.isNew));
Is this really the right approach? (it is working fine, from what i see until now)
The text was updated successfully, but these errors were encountered:
Then i wanted to list the entities in a View, so i had to parse it back to an Array.
You can keep an array of IDs when arrays are more convenient to work with. You'll need to do this for things like pagination. The real-world example in examples folder does that.
In my first App with Redux, I am trying to keep my collections normalised as recommended. This way you only have to change the Entities in one place. (this feels right to me)
At first i successfully normalised my Array of data to an Array-like-Object of Entities with the id's as key's
Then i wanted to list the entities in a View, so i had to parse it back to an Array. Also if i want to filter my Entities, i need the real Array. Is this really the right approach?
Example with re-select:
Is this really the right approach? (it is working fine, from what i see until now)
The text was updated successfully, but these errors were encountered: