Issue #804
<img
src={user.avatarUrl}
onError={(e) => {
e.target.onerror = null;
e.target.src = "/images/default.png"
}}
/>
Extract to React Component
interface Props {
src: string
className: string
fallback: string
}
export default function FallbackImg(props: Props) {
return (
<img className={props.className}
src={props.src}
onError={(e) => {
// @ts-ignore
e.target.src = props.fallback
}} />
)
}
How to fallback backgroundImage
Use 2 url
var el = document.createElement('div')
el.className = 'marker'
el.style.backgroundImage = `url('${user.avatarUrl}'), url('/images/user.png')`