Q:

How to store and import static files in React Native?

I would like to store static *.txt, *.svg, and even *.js files in a React Native project (clean, without any Expo and other wrappers, Webpacks, using Babel only) in assets folder (or other commonly preferred path). Then I would like to import them into the App.js as strings. There is so much contradictory info on the topic. How do I properly do that in a brand new app?

A:

If you have a json file like:
const data = {
  key1: 'value1',
  key2: 'value2',
};

export default data;

The only way to access your data is through:
import data from '../your/relative/path/to/data';

If you want to import specific key in that file, then your json file would be somthing like that:
export const key1 = 'value1';
export const key2 = 'value2';

const data = {
    key1,
    key2,
};

export default data;

Now you'd have the ability to do that:
import { key1 } from '../your/relative/path/to/data';

OR
import data from '../your/relative/path/to/data';

I suggest for text files, you store them in a constants folder, and make a a relevant .js file for each category:
constants.js file:
export const CONST_KEY_1 = 'some value';
export const CONST_KEY_2 = 'some other value';
export default {
    CONST_KEY_1,
    CONST_KEY_2
};

And for svg file:
Fast approach: to store the file_uri of each file in a key value pair in the same way we did in the constants.js file
Better approach: to store svg path of these svg files in the same form we did in the constants.js file ... and render these files using react-native-svg npm module.

