Skip to content

[Feature Request] Make a Distinction Between Loading and Error States in Image Component #3640

@Arian94

Description

@Arian94

Is your feature request related to a problem? Please describe.

When using the Image component, one would want to have two different images for the loading state as well as showing a fallback image when an error is encountered.

ATM, there is only one property called fallbackSrc that handles both states and displays one image, so there is no distinction between the loading and the error states.

Describe the solution you'd like

Please, make it possible to display another image on the Error state by adding a new property and modifying the use-image.ts file to handle such case.

Describe alternatives you've considered

Wrap the existing Image component and on the onError handler, set the fallbackSrc to point to another source like:

const [fallbackSrc, setFallbackSrc] = useState('');

<Image
    fallbackSrc={fallbackSrc}
    onError={() => {
         setFallbackSrc('/assets/another-img');
     }}
 ...
/>

Screenshots or Videos

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions