Friday 30 December 2022

How to add dynamic json in a build in react.js?

I have a react app that loads data from a local json file using

import data from './data.json'

it is all working fine without any issues and I'm able to open my index.html in 3000 and also open it as simple HTML page in browser.

Now I run npm run build which creates the build directory. However, my json values become kind of stagnant as it is hardcoded in the javascript in the build. So the question is how can my code in build directory reads json files from a specific location dynamically.



from How to add dynamic json in a build in react.js?

No comments:

Post a Comment