Skip to content

Commit e5691d6

Browse files
committed
Issue#24: Add a select form component for list of countries with autocomplete.
- [x] Add `CountrySelector` component which gives a select form with list of all the country names with autocomplete functionality - [x] Uses `react-select` component with `react-select-country-list`
1 parent 3bda54c commit e5691d6

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
1919
Mock server will run at [http://localhost:8080](http://localhost:8080).
2020

2121
Default login:
22+
2223
2324
- password: vyaguta
2425

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"moment": "^2.24.0",
1717
"node-sass": "^4.13.1",
1818
"pinterpolate": "^0.2.2",
19+
"prop-types": "^15.7.2",
1920
"react": "^16.13.1",
2021
"react-datepicker": "^2.14.1",
2122
"react-dates": "^21.8.0",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
import Select from 'react-select';
3+
import PropTypes from 'prop-types';
4+
5+
/**
6+
* A select form component.
7+
* A selector component which is an abstraction overt React Select.
8+
*
9+
* @component
10+
* @example
11+
* return (
12+
* <Selector
13+
* lists = the lists of data for the option
14+
* selected = the pre-selected item from the list
15+
* onChange = method invoked on selecting the item from the list.
16+
* />
17+
* )
18+
*
19+
* @param props
20+
*/
21+
const Selector = props => {
22+
return <Select options={props.lists} value={props.selected} onChange={props.onChange} />;
23+
};
24+
25+
Selector.propTypes = {
26+
/**
27+
* The list of options for the selector.
28+
*/
29+
lists: PropTypes.array,
30+
31+
/**
32+
* The selected item from the list of items.
33+
*/
34+
selected: PropTypes.object,
35+
/**
36+
* The handler method invoked when selecting the item from the list of items.
37+
*/
38+
onChange: PropTypes.func,
39+
};
40+
41+
export default Selector;

0 commit comments

Comments
 (0)