I am using bootstrap in one of our projects and there's this page where in I need to map over an array which will render a list of <InnerComponent />
in a grid of 3 columns. However, I needed to include the bootstrap column for each array child that the map function returns. And since <div>
is the direct child, then I have to put they 'key' property into it like so:
somearray.map((item, index) => {
return (
<div
className="col-lg-4 col-md-6 col-sm-12"
key={item.id}
>
<InnerComponent />
</div>
);
})
Is this valid? Or should the key be always added as a component prop?