Answers for "open modal on clicking select option in react"

0

open modal on clicking select option in react

import * as React from 'react';

export class Demo extends React.Component<{}, {}> {
  state = {
    options: [
      { text: 'doNothing', value: 'doNothing' },
      { text: 'openModal', value: 'openModal' }
    ],
    open: false
  };

  onClose = () => this.setState({open: false});
  onChange = (selected) => {
    // if the correct one is selected then...
    // this.setState({open: true});
  }

  render() {
    return (
      <div>
        <Dropdown
          fluid
          selection
          options={this.options}
          onChange={this.onChange}
          defaultValue={this.options[0].value} />

        <Modal open={this.state.open} onClose={this.onClose}>
          <Modal.Header>Select a Photo</Modal.Header>
          <Modal.Content image>
            <Modal.Description>
              <p>Some contents.</p>
            </Modal.Description>
          </Modal.Content>
        </Modal>
      </div>
    )
  }
}
Posted by: Guest on August-03-2021

Code answers related to "open modal on clicking select option in react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language