Skip to content
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

Image does not refresh if preload is true #394

Open
5 tasks done
davidvedvick opened this issue Apr 7, 2023 · 0 comments
Open
5 tasks done

Image does not refresh if preload is true #394

davidvedvick opened this issue Apr 7, 2023 · 0 comments

Comments

@davidvedvick
Copy link

Bug Report

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository?
  • Did you perform a search in the issues?

For more information, see the CONTRIBUTING guide.

Versions

2.1.17

Description

If preload is true on an <Image> component, it will not update the image if the src attribute is updated. This is especially problematic if navigation is managed by a library like React Router, which will re-use existing components, but, as proven by a unit test, will happen anywhere that src is set by a property.

Example Code with non-updating Image tag (edited for brevity and clarity):

function PureComponent(props: { imgSrc: string }) {

  return (<Image
    alt={'Job Image'}
    src={props.imgSrc}
    preload
    preloader={<ImageLoading />}
    error={<Error />}
  />);
}

Steps to Reproduce

  1. Add an <Image> component to a view which is rendered by React Router
  2. Try setting the src attribute using a dependency on a property.

Expected behavior: [What you expected to happen]

When src is updated, the new image should load.

Actual behavior: [What actually happened]

When src is updated, nothing happens.

Environment details: [OS, Browser, ...]

Verified on Edge 111.0.1661.62, Chrome 112.0.5615.49.

Possible Solution

I will post a fix shortly.

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

No branches or pull requests

1 participant