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 not updating when source changes #42

Open
ghost opened this issue Sep 9, 2022 · 1 comment
Open

Image not updating when source changes #42

ghost opened this issue Sep 9, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 9, 2022

Had an issue where the image wasn't updating. I looked into the code and concluded that this was due to the image proportions being the same values, so the image wasn't rerendering though it was a different image source, so it should've changed.

I suggest the following change;
(Adding props.source to the dependency's)

useEffect(() => {
        setImage(
            <ImageComponent
                {...props}
                style={[props.style, {
                    width: scalableWidth,
                    height: scalableHeight
                }]}
            />
        );
    }, [scalableHeight, scalableWidth, props.source]);
@lc3t35
Copy link

lc3t35 commented Nov 20, 2022

Thank you @tychocodifly -> This can be fixed with patch-package, create a file named "react-native-scalable-image+1.1.0.patch" in a "patches" folder, and setup as defined here : https://www.npmjs.com/package/patch-package

diff --git a/node_modules/react-native-scalable-image/index.js b/node_modules/react-native-scalable-image/index.js
index 655e3b3..ab034bb 100644
--- a/node_modules/react-native-scalable-image/index.js
+++ b/node_modules/react-native-scalable-image/index.js
@@ -48,7 +48,7 @@ const ScalableImage = props => {
                 }]}
             />
         );
-    }, [scalableHeight, scalableWidth]);
+    }, [scalableHeight, scalableWidth, props.source]);
 
     const onProps = localProps => {
         const { source } = localProps;

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