“Each child in an array should have a unique key prop” only on first time render of page

前端 未结 1 1233
生来不讨喜
生来不讨喜 2021-01-14 00:58

I have a with a bunch of inside that consists of all users logged in through Instagram. The is provid

相关标签:
1条回答
  • 2021-01-14 01:09

    You need to add the key property where you are rendering <component2>, not where you are defining it:

    component1 = React.createClass({
        render: () ->
            # A lot of table stuff here
            _.chain(@state.users).map((x) -> <component2 profile={x} key={x.id} />),@).value()
    )}
    
    component2 = React.createClass({
        render: () ->
            return (
                <tr>
                    <td>Blah</td>
                    <td>Blah</td>
                    <td>Blah</td>
                </tr>
            )
    })
    
    0 讨论(0)
提交回复
热议问题