Socket
Socket
Sign inDemoInstall

react-native-country-flags

Package Overview
Dependencies
0
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-country-flags

Library for importing flags by iso2 code in react-native apps.


Version published
Weekly downloads
29
decreased by-61.33%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

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={...}/>

FAQs

Last updated on 10 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc