react-native-country-flags
v1.1.0
Published
Library for importing flags by iso2 code in react-native apps.
Maintainers
Keywords
Readme
react-native-country-flags
Great way to import flag svgs dynamically
Why?
In reat-native you could not do dynamic imports. However, you could import all the files and then
export a dictionary with the mappings. This will be useful when you have to work with a large amount of flags.
Generate imports
All flags are stored under flags directory. If you are lazy and do not want to add the imports by hand
then run generator.py. It will output both the imports from flags like:
import AeFlag from './flags/ae.svg';
and flagMappings like:
ae: AeFlag,
ad: AdFlag,All you have to do is to copy them in index.js and you are good to go.
Usage
import { flagMappings } from 'react-native-country-flags';
const Flag = flagMappings['ae'];
return <Flag width={24} height={24} style={...}/>