Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
428 views
in Technique[技术] by (71.8m points)

reactjs - 尽管存在密钥,但Gatsby React密钥属性错误(Gatsby React key property error, despite key is there)

I have the following ul in react: (I know that using index is not always the best idea. Just for simplicity)

(我有以下ul反应:(我知道使用索引并不总是最好的主意。只是为了简单起见))

  <ul>
    {project.topics.map((topic, i) =>
      <li key={i}>{topic}</li>
    )}
  </ul>

which results in the following warning:

(这将导致以下警告:)

Warning: Each child in a list should have a unique "key" prop.

Check the render method of `CvPage`. See .... for more information.
   in projectCard (at cv.js:22)

Why does react complain about the key property, despite it being there?

(为什么反应会抱怨关键资产,尽管它在那里?)

The HTML looks like this:

(HTML看起来像这样:)

html

  ask by Console translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...