V
V
Valery Zhmyshenko2017-10-30 11:56:56
JSON
Valery Zhmyshenko, 2017-10-30 11:56:56

How to parse such a json object?

Good afternoon!
It comes from the json server, then I translate it into an object through JSON.parse(). Then I want to display its contents like this: Object.keys(this.state.students).map(function (val){return });
But in reality, one empty element is rendered, and the error "Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `RenderStudent`" is thrown.
59f6e7b27c5a1935685172.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alexandrovich, 2017-10-30
@kiril_murr

try this

Object.keys(this.state.students).map(
   (el, ind)=>{
       <div key={el.id}>{el.name}</div>
   }
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question