Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
January 21, 2023 07:20 pm GMT

JSON maping in ReactJS

  • Create a JSON file with .js extension

Data.js

const JSONdata = [  {    id: 1,    quote: "Life isnt about getting and having, its about giving and being.",    author: "Kevin Kruse",  }, {    id: 2,    quote: "Whatever the mind of man can conceive and believe, it can achieve.",    author: "Napoleon Hill",  },]

App.js

import React from "react";import JSONdata from "../Data";const Home = () => {  return (    <>      {JSONdata.map((dataForMap) => {        return (          <>            <center>              <h1>------------------</h1>              <p>{dataForMap.id}</p>              <p>{dataForMap.quote}</p>              <h4>{dataForMap.author}</h4>            </center>          </>        );      })}    </>  );};export default Home;

Finally Done !!!


Original Link: https://dev.to/raynecoder/json-maping-in-reactjs-1f84

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To