Created
July 31, 2018 22:36
-
-
Save grantglidewell/40660e7462eaa0bc3a697a44d7e8c98e 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
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