-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(Dropdown): add dedicated example for controlled Dropdown (#2251)
- Loading branch information
1 parent
5841dd7
commit 28c8af9
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
docs/app/Examples/modules/Dropdown/Usage/DropdownExampleControlled.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { Component } from 'react' | ||
import { Dropdown, Grid, Segment } from 'semantic-ui-react' | ||
|
||
const options = [ | ||
{ key: 1, text: 'One', value: 1 }, | ||
{ key: 2, text: 'Two', value: 2 }, | ||
{ key: 3, text: 'Three', value: 3 }, | ||
] | ||
|
||
export default class DropdownExampleControlled extends Component { | ||
state = {} | ||
|
||
handleChange = (e, { value }) => this.setState({ value }) | ||
|
||
render() { | ||
const { value } = this.state | ||
|
||
return ( | ||
<Grid columns={2}> | ||
<Grid.Column> | ||
<Dropdown | ||
onChange={this.handleChange} | ||
options={options} | ||
placeholder='Choose an option' | ||
selection | ||
value={value} | ||
/> | ||
</Grid.Column> | ||
<Grid.Column> | ||
<Segment secondary> | ||
<pre>Current value: {value}</pre> | ||
</Segment> | ||
</Grid.Column> | ||
</Grid> | ||
) | ||
} | ||
} |
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