react-country-select
Project Title
React-country-select-amn
Getting Started
Component which is often use in react-forms. Gives dropdown of all the countries with their flag icons.
with added prop tag.
Dependencies
react-select, style-loader, css-loader
####You need to download all the flag icons
You can either download zip from https://github.com/gunjan4455/Flagicons
or git clone https://github.com/gunjan4455/Flagicons.git
This will give you all the flag icons used in the dropdown. Save the flags folder in your public folder.
Installing
npm install react-country-select-amn --save
Parameters :
Mandatory parameter
flagImagePath="path to your folder containing all flag icons"
onSelect={function which will return options selected}
Not Mandatory
multi={false} //for single selection
multi={true} //for multiple selection
By default it is single selection mode
Example
import React, {Component} from "react";
import CountrySelect from "react-country-select";
export default class App extends Component {
propTypes : {
onSelect: React.PropTypes.func
}
constructor(props) {
super(props);
this.state = {
tag: null,
};
this.onSelect = this.onSelect.bind(this);
}
onSelect(val) {
console.log("values selected are:", val);
//you can handle options selected here.
}
render() {
return (
<div>
<CountrySelect multi={true} flagImagePath="./assets/flags/" onSelect={this.onSelect}/>
</div>
);
}
}