react-native-scalable-image icon indicating copy to clipboard operation
react-native-scalable-image copied to clipboard

Image not updating when source changes

Open ghost opened this issue 3 years ago • 1 comments

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]);

ghost avatar Sep 09 '22 12:09 ghost

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;

lc3t35 avatar Nov 20 '22 16:11 lc3t35