K
K
kirillleogky2020-02-12 21:36:00
JavaScript
kirillleogky, 2020-02-12 21:36:00

How to solve jsx-a11y/click-events-have-key-events and jsx-a11y/no-noninteractive-element-interactions issue?

jsx code:

return (
      <li
        className="answers_block-answer answer"
        key={answer}
        onClick={handleClick}
      >
        <span className="answer_point" />
        {answer}
      </li>
    )


How to solve the problem with these errors:
5e44458e4ec47294829732.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Klein Maximus, 2020-02-13
@kleinmaximus

If you are using a NOT interactive element (for example, a div, not a button), then add at least one event handling from onKeyUp, onKeyDown, onKeyPress.
https://github.com/evcohen/eslint-plugin-jsx-a11y/...
Or start using interactive elements button, link, checkbox, menuitem, menuitemcheckbox, menuitemradio, option, radio, searchbox, switch, textbox
https:/ /github.com/evcohen/eslint-plugin-jsx-a11y/...
The easiest, but also the WORST option is to disable linter for specific rules in this file (insert at the beginning of the file):

/* eslint-disable jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions */

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question