Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera
Last active April 26, 2018 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uno-de-piera/2ad6c8c201a40f8df9fdfdeb8d73e23f to your computer and use it in GitHub Desktop.
Save uno-de-piera/2ad6c8c201a40f8df9fdfdeb8d73e23f to your computer and use it in GitHub Desktop.
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