0

I keep the receiving an linting warning when using the 'onerror' event on img. Any thoughts on how to resolve this?

Error: Non-interactive elements should not be assigned mouse or keyboard event listeners

jsx:

const handlerErrorNoImage = (event) => {
    event.target.src = blankProfile
  }

<img src="./myimage" onError={handlerErrorNoImage} alt="" />
user992731
  • 3,400
  • 9
  • 53
  • 83

1 Answers1

0

I hadn't researched why onError is interpreted as a mouse or keyboard event. However, below at least removes the warning:

// eslint-disable <img src="./myimage" onError={handlerErrorNoImage} alt="" /> // eslint-enable

tallman
  • 129
  • 1
  • 3
  • 10