#React.js

How to read local JSON files in React.js?

Rajdeep Singh
FrontEnd web
3 min readNov 18, 2019

--

react js tutorial by Rajdeep Singh

Hey everybody, my name is Rajdeep Singh. In this post, I’m telling you How to read the JSON file in react.js within a simple step.

Demo And Code Here

Requirement

  1. No Need for Axios or Fetch
  2. Import File
  3. Map() Method ( Function)
  4. QNA

Look Like this Example:

Step: 1

Import the JSON file. On your work file, uses the Import method.

import data from ‘./data/data.json’;

Step: 2

when you import after using the map() method, loop all the items in the JSON file.

Interesting fact map() method used only for the array. But in our JSON file Format…

--

--

Rajdeep Singh
FrontEnd web

JavaScript | TypeScript | Reactjs | Nextjs | Rust | Biotechnology | Bioinformatic | Frontend Developer | Author | https://linktr.ee/officialrajdeepsingh