react-native-scalable-image
react-native-scalable-image copied to clipboard
Image not updating when source changes
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]);
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;