I have some expensive computations to do in JS in a React Native project where I need to use a lot of pre-computed datas.
I have exported these in JSON files (each ~2MB) that I'm loading when I need them like so :
export const getDataShootAngle = () => {
return [
require('./parsed_phi1.json'),
require('./parsed_phi2.json'),
require('./parsed_phi3.json'),
require('./parsed_phi4.json'),
require('./parsed_phi5.json'),
require('./parsed_phi6.json'),
];
};
But when I do this I get the error :
Error: Requiring module "algorithm\data\parsed_phi6.json", which threw an exception: RangeError: Maximum call stack size exceeded, js engine: hermes
Is there a way to load big amount of data in React Native ? I would be okay to export my data in a binary format but I have no idea of how I would do this.
Also, I guess it would be nice if I could only load the data once it's needed (kinda what I tried to do with the require()
directly inside of a function instead of using an import at the top of the file).
Edit :
I am using Expo to develop my app so I was testing it using Expo Go. I just tried to compile it to an .apk
and it turns out the bug doesn't come in this context. I guess this is a limitation with Expo Go, would be nice if there was still a way to debug the app though.