behavior when src is null
ssmlee04 opened this issue · comments
I assume when src is null or "" or undefined the "image not found" area should be loaded? Or this is not what it is expected to do? Thanks.
Hi @ssmlee04, sorry for taking a while to get back to you.
The behavior you describe is the way it's designed–the alt content will only be shown if the load fails. However, if you provide a preloader
prop, that will be rendered when src is null
(or undefined
). To achieve what i think you're looking to do, you could use the same content for both the preloader and the alt content, for example:
// in some component class...
render() {
function preloader() {
return <div>Hey, where is my img?</div>;
}
return (
<ImageLoader preloader={preloader}>
{preloader}
</ImageLoader>
);
}
Let me know if that helps!
got it. ya it seems to be a better approach then just display "image not found". Thanks and lemme try it in a bit.