How to display data in ract js using map function

In this article I am going to show display data to web page in react using map function

Example

import React from "react";
export default function App() {

  const products = [

    {
      id: 1,
      name: "iPhone",
      price: 654,
    },
    {
      id: 2,
      name: "Samsung",
      price: 454,
    },
    {
      id: 3,
      name: "Nokia",
      price: 214,
    },

  ];

  return (
    <div>

      {products
        ? products.map((product) => {

            return (
              <div key={product.id}>
                <p>Name: {product.name}</p>
                <p>Price: {product.price}</p>
              </div>
            );

          })
        : null}

    </div>
  );
}

 

About Author

Photo

Hi, I am Mahbub Hasan
Software Engineer

I am very much interested to share my programming
and development knowledge with the people.I will try
to update my blog everyday with new technology inshallah.

Thank You

For Visiting My Blog.

Contact Me