open modal on clicking select option in react

Solutions on MaxInterview for open modal on clicking select option in react by the best coders in the world

showing results for - "open modal on clicking select option in react"
Fabio
02 Aug 2018
1import * as React from 'react';
2
3export class Demo extends React.Component<{}, {}> {
4  state = {
5    options: [
6      { text: 'doNothing', value: 'doNothing' },
7      { text: 'openModal', value: 'openModal' }
8    ],
9    open: false
10  };
11
12  onClose = () => this.setState({open: false});
13  onChange = (selected) => {
14    // if the correct one is selected then...
15    // this.setState({open: true});
16  }
17
18  render() {
19    return (
20      <div>
21        <Dropdown
22          fluid
23          selection
24          options={this.options}
25          onChange={this.onChange}
26          defaultValue={this.options[0].value} />
27
28        <Modal open={this.state.open} onClose={this.onClose}>
29          <Modal.Header>Select a Photo</Modal.Header>
30          <Modal.Content image>
31            <Modal.Description>
32              <p>Some contents.</p>
33            </Modal.Description>
34          </Modal.Content>
35        </Modal>
36      </div>
37    )
38  }
39}
40