I have a React component and I want to load in my JSON data from a file. The console log currently doesn\'t work, even though I\'m creating the variable data
You could add your JSON file as an external using webpack config. Then you can load up that json in any of your react modules.
Take a look at this answer
install json-loader
:
npm i json-loader --save
create data
folder in src
:
mkdir data
put your file(s) there
load your file
var data = require('json!../data/yourfile.json');