I'm using normalizr to normalize a response.
My problem is that I don't know how to manage the normalized response.
{
result:[]
entities: {
words: {
//...
1: {
definitions: [1, 2, 3]
}
// other word objects...
},
definitions: {
1: 'blah blah'
2: 'blah blah'
3: 'blah blah'
// definition objects
}
}
}
I want to pass the words to a react component with definitions. How can I retrieve the words with nested definitions and render it to my component.
webpackbin DEMO
assuming that your state looks something like this
then... WordList may looks like this. Slice ids of words from state, in order to render list
and Word component: Get particular word from state by id from props, calculate definitions list through map
and DefinitionsList
Functional compontent was used just for short.