DOM events

onError

Resource load failures can be reported by an element event. This is not a React error boundary. Use bounded fallback behavior rather than repeatedly changing to another failing URL.

Formal Syntax & Structure

react syntaxreact
onError={handler}

Working Example

Example Snippetreact
import {useState} from 'react';export default function App({src}){const [failed,setFailed]=useState(false);return failed?<p>Image unavailable</p>:<img src={src} alt='Tool' onError={()=>setFailed(true)}/>}
React Reference