0

My use case is kind of what I have simplified in below example. How to render components sharing same trigger?

class SomeComponent extends Component {

    render() {
        let dropDownItem = <DropDown.Item> An Item! </DropDown.Item> 

        let modal = <Modal trigger={dropDownItem}></Modal>

        let popup = <Popup trigger={dropDownItem}></Popup>

        return(
                  <DropDown.Menu>
                        {modal} or {popup} 
                  // How to share same trigger among multiple components.
                  <DropDown.Menu>
              )
    }
}
t0il3ts0ap
  • 530
  • 4
  • 18

2 Answers2

0

I believe you can place one inside the other. In this instance, it would be

class SomeComponent extends Component {

render() {
    let dropDownItem = <DropDown.Item> An Item! </DropDown.Item> 

    let modal = <Modal trigger={dropDownItem}></Modal>

    let popup = <Popup trigger={modal}></Popup>

    return(
              <DropDown.Menu>
                {popup} 
              <DropDown.Menu>
          )
}}
MEnf
  • 1,482
  • 1
  • 12
  • 18
0

One solution would be to let Modal not use a trigger, but rather control it's visibility using Modal's open property:

<Modal open={this.state.isOpen}>Content</Modal>

On clicking the dropdown item, you'd set this.state.isOpen = true and the modal would be shown.

michaelpoltorak
  • 464
  • 4
  • 6