Q: Is it okay to have the same keys for different list items rendered within separate map
functions in the same React component?
<>Situation: 如你在实例代码中所示,将指数作为<代码>key识别码的Im。 两者都将从0、1、2、3开始。
(Both initialMessageData
and messageData
are dynamic, changing over time)
www.un.org/Depts/DGACM/index_spanish.htm 守则例:
...
...
return (
<ul>
{initialMessageData.map((data, index) => (
<ChatLog key={index} data={data} />
))}
{messageData.map((data, index) => (
<ChatLog key={index} data={data} />
))}
</ul>
);
- If it is okay, why?
- If it is not okay, why?