Answer the question
In order to leave comments, you need to log in
How to sort after applying normalizr?
There is an api request on the react/redux stack. The following data comes in:
[
{...},
{...},
{...},
]
result
objects entities
. Fields from entities
are stored in store
. Then the task is to sort the object by some field, but normalizr turns the array into an object and it becomes difficult to sort it. The question is how to do it right? entities.users[id]
. The downside is that normalizr already creates an array to iterate over id result
. You will either have to change it or make a new one. Answer the question
In order to leave comments, you need to log in
somehow it's all far-fetched, who's stopping you from writing something like
result.sort((a, b) => entities.data[a].sortField - entities.data[b].sortField).map(id=>this.renderData( entities.data[id]) )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question