I'm changing the code of a working react app. There is a piece of code that imports and process a couple of json files:
import dataAjson from "./data/a.json";
import dataBjson from "./data/b.json";
datasets = [
{
info: {id: 'a'},
data: processGeojson(dataAjson)
},
{
info: {id: 'b'},
data: processGeojson(dataBjson)
}
]
I want to change this code so it will automatically process all files from the ./data
folder. I'm a newbie to TypeScript tool chain, and I don't know all the impacts that changing the import
will have in my app.
The data files are somewhat large. All the files will be present in the data folder when the app starts. Since react executes in the client, maybe I must make a get request.
What's the best way to load these files? Or what are the pros and cons of each approach?