Skip to content
Advertisement

Extract values from list of dictionaries and populate component

In my Class component, I have a list of 9 dictionaries as props:

JavaScript

Each dictionary key, value structure:

JavaScript

Now I need to extract dictionary ‘name’ values and display them as text in my component.

For every group of three rows, the value must satisfy the condition of its unique ‘position’, that is, 3 names for ‘fwd’, then 3 names for ‘mid’, then names 3 for ‘def’, until the list is emptied.


This is the render:

JavaScript

Examples of expected result:

JavaScript

How do I extract the values using that condition and keeping the structure above?

Advertisement

Answer

I guess this is how i would do it.

JavaScript

Edited: It doesn’t feel like it’s an good idea but i guess following would give you the correct output

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement