I'm working on including some flags to represent countries in my react native project. I discovered that you can't dynamically require images like the example below in react native.
require(`../assets/flags/32/${countryCode}.png`) So given the SO response I found here I was thinking of creating a function with a switch statement that would return the required image back when passed the correct flag code. Something like the below.
export const Flags = (countryCode) => { switch (countryCode) { case 'US': return require('../assets/flags/32/US.png'); .... } }; I'll have well over 200 cases given this solution. Is there some better way to do this?