[Avatar] Adding support for Framework image #3154
Open
+114
−91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Hi Team,
I'm proposing a new suggestion to address issue #2230 on top of existing PR #2999
I've implemented this solution by removing the prefetch image which helps to determine the image loading error.
Since
Primitive.img
already handlesOnLoad
andOnError
events, it makes sense to leverage these callbacks for handling image load failures in a single fetch.Changes Introduced
Primitive.img
is displayed, and itsOnLoad
andOnError
callbacks are subscribed through an intermediate handler:style.display
is set tonone
.display
property is updated to the user-specified value.null
to display the fallback.useImageLoadingStatus
custom hook, simplifying the image loading process:primitives/packages/react/avatar/src/Avatar.tsx
Line 119 in 6469d41
NOTE: I don't find any other use-case of
useImageLoadingStatus
hook, other than tracking image loading statusWhat This Solves
Visual Comparison
Before:
before.mp4
After:
after.mp4
EDIT:
Upon toggling
Disable Cache
off It makes only one request