Вставить ID в React Modal - PullRequest
       35

Вставить ID в React Modal

1 голос
/ 01 апреля 2019

Я использую https://react.semantic -ui.com / modules / modal / этот модал.Я хотел бы добавить атрибут id в div, который имеет класс modal.Как я могу это сделать ?

enter image description here

1 Ответ

1 голос
/ 01 апреля 2019

Вы пытались просто добавить id реквизит?:

<Modal
  trigger={<Button onClick={this.handleOpen}>Show Modal</Button>}
  open={this.state.modalOpen}
  onClose={this.handleClose}
  basic
  size='small'
  id="theIdHere"
>
...

у меня это сработало

<div class="ui page modals dimmer transition visible active" style="display: flex !important;">
  <div id="theIdHere" class="ui small basic modal transition visible active">
  ...

Однако, modal div доступен только после модальногопоказано, поэтому будьте осторожны, чтобы прикрепить событие к модальному open и удалить после закрытия модального

...