Skip to content

fix(ui-react-storage): StorageImage showing fallback text while the image is still fetching #6426

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

Closed

Conversation

aadimch
Copy link
Contributor

@aadimch aadimch commented Mar 12, 2025

Description of changes

Currently, when using StorageImage, the user would see the fallback text while the image is still being fetched. The issue is more prominent when the network is throttled.

This PR uses the loading state exposed by useGetUrl and returns a View with the provided styles while the image is being fetched.

Issue #6254

Checklist

  • Have read the Pull Request Guidelines
  • PR description included
  • yarn test passes and tests are updated/added
  • PR title and commit messages follow conventional commit syntax
  • If this change should result in a version bump, changeset added (This can be done after creating the PR.) This does not apply to changes made to docs, e2e, examples, or other private packages.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

changeset-bot bot commented Mar 12, 2025

⚠️ No Changeset found

Latest commit: ca575e7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR


return (
<Image
{...rest}
style={{ ...style }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, no need to spread style and create a new object here

Comment on lines +105 to +107
if (isLoading) {
return <View style={{ ...style }}></View>;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than destructure style, let's add a loadingElement key on StorageImageProps and render it conditionally while isLoading is true if provided.

interface StorageImageProps {
  loadingElement?: React.ReactNode;
}

@aadimch
Copy link
Contributor Author

aadimch commented Apr 8, 2025

Closed in favor of #6448

@aadimch aadimch closed this Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants