react-native-country-iso-selector
is a React Native component library that provides a country selector with ISO codes and flags.
To install the library, use npm or yarn:
npm install react-native-country-iso-selector
or
yarn add react-native-country-iso-selector
Example using in popover component
Here is an example of how to use the CountrySelector
and SelectedCountryDisplay
components:
import React, { useState } from 'react';
import { View } from 'react-native';
import { CountrySelector, SelectedCountryDisplay } from 'react-native-country-iso-selector';
const App = () => {
const [selectedCountry, setSelectedCountry] = useState(null);
return (
<View>
<CountrySelector
setCountry={setSelectedCountry}
placeholder="Select a country"
leftComponent={<YourCustomComponent />}
/>
<SelectedCountryDisplay
country={selectedCountry}
iconSize={20}
iconColor="blue"
/>
</View>
);
};
export default App;
-
setCountry
: Function to set the selected country. -
placeholder
: Placeholder text for the search input. -
leftComponent
: Custom component to display on the left side of the search input.
-
country
: The selected country object. -
styleContainer
: Custom style for the container. -
styleInnerContainer
: Custom style for the inner container. -
styleFlag
: Custom style for the flag image. -
iconSize
: Size of the chevron icon. -
iconColor
: Color of the chevron icon.
interface Country {
country_name: string;
iso2: string;
e164_code: number;
}
interface CountrySelectorProps {
setCountry: (country: Country) => void;
placeholder: string;
leftComponent: React.ReactNode;
}
interface SelectedCountryDisplayProps {
country: Country | null;
styleContainer?: StyleProp<ViewStyle>;
styleInnerContainer?: StyleProp<ViewStyle>;
styleFlag?: StyleProp<ImageStyle>;
iconSize?: number;
iconColor?: string;
}
This project is licensed under the ISC License.
Hesler Dennis