Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- import './App.css';
- import DropdownButton from 'react-bootstrap/DropdownButton';
- import Dropdown from 'react-bootstrap/Dropdown';
- class App extends React.Component {
- constructor() {
- super();
- this.state = {
- dropDownValue: "Select an item"
- }
- }
- changeValue(text) {
- this.setState({dropDownValue: text})
- }
- render() {
- return (
- <div className="App">
- <header className="App-header">
- </header>
- <div>
- <DropdownButton id="dropdown-item-button" title={this.state.dropDownValue} className="format">
- <Dropdown.Item as="button"><div onClick={() => this.changeValue(this.textContent)}>Item #1</div></Dropdown.Item>
- <Dropdown.Item as="button"><div onClick={() => this.changeValue(this.textContent)}>Item #2</div></Dropdown.Item>
- <Dropdown.Item as="button"><div onClick={() => this.changeValue(this.textContent)}>Item #3</div></Dropdown.Item>
- </DropdownButton>
- </div>
- </div>
- );
- }
- }
- export default App;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement