Storing database json file in optimal way for react native app

Viewed 500

I’m using react native, redux and firebase and I have a 1 MB database export that contains food nutritional information from the Canadian Nutrition File database.

This data will never change and is used in a FlatList users can search and import from.

What’s the optimal way for me to store this for my users to access as fast as possible when searching?

I am thinking of simply including the json file with my other source files and calling it from there using require.

But since I have firebase and redux all setup I wondered if it made more sense for whatever reason to consider those options instead.

Thanks in advance for any input.

1 Answers

Since you are already using redux, i'd go for adding the json content to the store on app init/mount so you can get it easily from everywhere.

Another options i'd consider:

  1. Import, parse & render the JSON file stactically on runtime (as it never changes);
  2. Use the AsyncStorage to make it available in local database but outsite the redux store thing.
Related