can we map the website using arrays of objects and display components?

Simply pass the arrays as a prop to CardComponent, such as a data prop.

<CardComponent data={data1} />
<CardComponent data={dataTwo} />

And map the passed data prop in CardComponent. Remember that the mapping needs to return everything wrapped in a single node (i.e. div, Fragment, etc..) and should have an attached react key.


const CardComponent = ({ data }) => {
  return (
      {, index) => {
        return (
          <Fragment key={index}>
            <Img src={data.img} />

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top