Skip to content

Instantly share code, notes, and snippets.

@grantglidewell
Created July 31, 2018 22:36
Show Gist options
  • Save grantglidewell/40660e7462eaa0bc3a697a44d7e8c98e to your computer and use it in GitHub Desktop.
Save grantglidewell/40660e7462eaa0bc3a697a44d7e8c98e to your computer and use it in GitHub Desktop.
export class SelectGuide extends Component {
state = {
value: 'Initial message',
text: 'Initial'
}
render() {
return (
<React.Fragment>
<p>
The Select component requires that you also import the Option
component to nest inside of it for each option. It takes an onSelect
prop.
</p>
<Select
selection={{ value: this.state.value, text: this.state.text }}
onSelect={this.handleSelect}>
<Option key="1" value="1" text="Selection 1" />
<Option key="2" value="2" text="Selection 2" />
<Option key="3" value="3" text="Selection 3" />
</Select>
</React.Fragment>
)
}
handleSelect = evt => {
this.setState({
value: evt.target.dataset.value,
text: evt.target.dataset.text
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment