<img src="someImage.png" onerror="someErrorFunction(this);"/>
Just curious what's the equivalent of onerror
for Avatar component. I looked up the documentation, couldn't find anything useful. Avatar Documentation
@temurih It's a duplicate of #5257.
We have added a test case for it on the v1-beta branch:
https://github.com/mui-org/material-ui/blob/3e4854b39b17511d9b312071ca93061eeb503f5d/packages/material-ui/src/Avatar/Avatar.test.js#L51-L55
I am not sure what that means, but I guess I can implement this of my own.
@temurih It means that the onError property can be used on v1-beta. It also means that v0.x is no longer maintained.
for anyone else looking for an example for this,
you can now do:
<Avatar
src={imgSrc}
imgProps={{ onError: (e) => { e.target.src = defaultImage(); } }}
/>
to use another img if it errors out on load
Most helpful comment
for anyone else looking for an example for this,
you can now do:
to use another img if it errors out on load