[Avatar] Adding support for Framework image#3154
Closed
Udhayarajan wants to merge 5 commits into
Closed
Conversation
…and OnLoad callback from Primitive.img to deduct the image loading status
…pular Frameworks' image component
…er to simulate the onload
Member
|
Planning to handle this a little differently #3943 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.imgalready handlesOnLoadandOnErrorevents, it makes sense to leverage these callbacks for handling image load failures in a single fetch.Changes Introduced
Primitive.imgis displayed, and itsOnLoadandOnErrorcallbacks are subscribed through an intermediate handler:style.displayis set tonone.displayproperty is updated to the user-specified value.nullto display the fallback.useImageLoadingStatuscustom 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
useImageLoadingStatushook, other than tracking image loading statusWhat This Solves
Visual Comparison
Before:
before.mp4
After:
after.mp4
EDIT:
Upon toggling
Disable Cacheoff It makes only one request