-
Notifications
You must be signed in to change notification settings - Fork 776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avatars flash on mount even if cached #2044
Comments
This ticket could be closed: #2340 |
@frykten, it does not fix this judging by the code. |
This is also the case when providing a base64 string as src. I'm expecting the component not to flash and show fallback, but render the image directly since there's no network request involved here. However, I see the state moving from Reproduction: https://codesandbox.io/s/radix-avatar-b64issue-rr24j8 |
+1 |
1 similar comment
+1 |
+1 |
+1 |
1 similar comment
+1 |
Bug report
Current Behavior
Avatars never render on first mount, even if cached.
Expected behavior
If avatar image is cached by the browser, the image should render straight away on initial mount.
Reproducible example
Refresh this page: https://www.radix-ui.com/docs/primitives/components/avatar
Suggested solution
Instead of loading the image in useEffect, the image loading should be started directly in the useState initializer. If the image is cached,
image.complete
ofnew Image
will return true synchronously, and then the state value can be returned as "loaded" right away.The text was updated successfully, but these errors were encountered: