Can I add a key prop to a React fragment?

前端 未结 1 1195
渐次进展
渐次进展 2021-01-01 09:15

I am generating a dl in React:

      
{ highlights.map((highlight, i) => {
相关标签:
1条回答
  • 2021-01-01 09:41

    To add a key to a fragment you need to use full Fragment syntax:

    <React.Fragment key={your key}>
    ...
    </React.Fragment>
    

    See docs here https://reactjs.org/docs/fragments.html#keyed-fragments

    0 讨论(0)
提交回复
热议问题