C
C
cester2018-03-15 16:17:03
JavaScript
cester, 2018-03-15 16:17:03

Walk through an object in React?

Good afternoon! Please tell me how it is better to walk through the object in react and display the data (as in the array)?
It’s just that a different object can come ...
I don’t want to use cycles in the component, output separately through Object.keys(obj)and Object.values(obj)somehow not very ...
Such a record through lodash does not work for some reason

{_mapKeys(values, (val, name) => (
              <BlockItemComp
                name={name}
                val={val}
              />
          ))}

What is another option?
I will be grateful!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-03-15
@cester

Object.entries(obj).map(([ key, val ]) => (
  <BlockItemComp
    name={key}
    val={val}
  />
))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question