REACT Missing “key” prop for element

https://*.com/questions/48266018/missing-key-prop-for-element-reactjs-and-typescript

When rendering an array of elements, React needs a key prop (1) to identify elements and optimize things.

Add key={topic.id} to your element in jsx:

return (
<div>
<h2>Results List</h2>
{topics.map((topic: any) =>
<div className="panel panel-default" key={topic.id}>
<div className="panel-heading">{topic.name}</div>
<div className="panel-body">{topic.description}</div>
</div>
)}
</div>
);
上一篇:JavaScript中undefined与null的区别


下一篇:三十三、DNS资源记录类型和请求流程