I'm using expo react-native. I want to store all my images in one file and from there import it to my components when I need, I just don't know how to write it.
Right now I used in Clumsy and complicated and unreadable way like this:
Constant file "Images" to hold all the pictures:
export const t1 = require("../assets/images/t1.jpg");
export const t2 = require("../assets/images/t2.jpg");
export const t3 = require("../assets/images/t3.jpg");
export const t4 = require("../assets/images/t4.jpg");
export const s1 = require("../assets/images/s1.jpg");
export const s2 = require("../assets/images/s2.jpg");
export const s3 = require("../assets/images/s3.jpg");
export const s4 = require("../assets/images/s4.jpg");
export const r1 = require("../assets/images/r1.jpg");
and from each component that i need the images I just import it:
import { t1, t2, t3, t4 } from "./Images";
...
<Image source={t1} ..........
It works great, but I want to know how to save the constant images in json file I understand that is more efficient way to hold the images
Thanks a lot