-
-
Save uno-de-piera/2ad6c8c201a40f8df9fdfdeb8d73e23f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListSelect extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { selected: null }; | |
} | |
render() { | |
let items = [{ 'name': 1, value: 1 }, { 'name': 2, value: 2 }]; | |
return ( | |
<select value={this.state.selected || ''} onChange={e => this.setState({ selected: e.target.value || null })}> | |
{ | |
items.map(function (item) { | |
return <option value={item.name}>{item.name}</option>; | |
}) | |
} | |
</select>); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment