案例 1)我正在尝试使用 map 和三元运算符有条件地渲染。在这里,我迭代了一个对象数组,然后只渲染其中的前六个。试图达到同样的效果,但它似乎并不奏效。
帮助将不胜感激
目的
const recentEventsData = [
{ key: "01", text: "AAA", timestamp: "11:52:27:02 02-11-2019" },
{ key: "02", text: "BBB", timestamp: "11:52:29:02 02-11-2019" },
{ key: "03", text: "CCC", timestamp: "11:52:30:02 02-11-2019" }
];
内部渲染()
{
recentEventsData.map((data, index) => {
{
index < 6 ? (
<div key={index}>
//Want the transformed output here , that is fourth value from object
<p>{data.text}</p>
<p>{data.timestamp}</p>
<hr />
</div>
) : null;
}
});
}