//Bad case
{someData.map(item =>(
<div key={item.id}> hello! </div>
))}
//Good case
{React.Children.toArray(
someData.map(item =><div> hello! </div>)
)}
React.Children.toArrayを利用する場合、key属性は要らなくなります。
More than 1 year has passed since last update.
//Bad case
{someData.map(item =>(
<div key={item.id}> hello! </div>
))}
//Good case
{React.Children.toArray(
someData.map(item =><div> hello! </div>)
)}
React.Children.toArrayを利用する場合、key属性は要らなくなります。
Register as a new user and use Qiita more conveniently