T
T
Tolik2282021-08-31 13:37:54
UIkit
Tolik228, 2021-08-31 13:37:54

I make a modal window through UIkit and when assigning an event to a link in React, it does not respond at all?

const ChooseModal = ({target, data, redirect, modal}) => {
        

    const pageList = data.map(item => {
      return (
        <li key={item}>
                <a 
                className="uk-link-muted" 
                href='#'
                onClick={(e) => redirect(e, item)}
                >{item}</a>
        </li>
        )
      })

    return (
      <>
        <div id={target} data-uk-modal={modal.toString()}>
              <div className="uk-modal-dialog uk-modal-body">
                  <h2 className="uk-modal-title">Открыть</h2>
                  <ul className="uk-list uk-list-striped">
                      {pageList}
                  </ul>
                  <p className="uk-text-right">
                      <button 
                      className="uk-button uk-button-default uk-modal-close" 
                      type="button"
                      >Отменить</button>
                  </p>
              </div>
          </div>
      </>
    )
}

(Tried to fix it with React Portal but then the trigger button doesn't see the modal window and doesn't open it)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Olovyannikov, 2021-08-31
@cannibal_corpse

Because a link is a link, not a button.
To interact with elements, use buttons of the button type.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question