1class ParentComponent extends React.Component {
2
3 state = { language: '' }
4
5 handleLanguage = (langValue) => {
6 this.setState({language: langValue});
7 }
8
9 render() {
10 return (
11 <div className="col-sm-9">
12 <SelectLanguage onSelectLanguage={this.handleLanguage} />
13 </div>
14 )
15 }
16}
17
1var json = require("json!../languages.json");
2var jsonArray = json.languages;
3
4export class SelectLanguage extends React.Component {
5 state = {
6 selectedCode: '',
7 selectedLanguage: jsonArray[0],
8 }
9
10 handleLangChange = () => {
11 var lang = this.dropdown.value;
12 this.props.onSelectLanguage(lang);
13 }
14
15 render() {
16 return (
17 <div>
18 <DropdownList ref={(ref) => this.dropdown = ref}
19 data={jsonArray}
20 valueField='lang' textField='lang'
21 caseSensitive={false}
22 minLength={3}
23 filter='contains'
24 onChange={this.handleLangChange} />
25 </div>
26 );
27 }
28}
29