//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属性は要らなくなります。
Go to list of users who liked
More than 3 years have 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
Go to list of users who liked