react-native-awesome-gallery
react-native-awesome-gallery copied to clipboard
Web compatibility
Hi 👋
I'm trying to make this package work with web. I checked the issues, an old one here mentioned that this package isn't compatible with web: https://github.com/pavelbabenko/react-native-awesome-gallery/issues/42
I actually believe it's 99% compatible with web. I use this package with an expo app, on web. I'm getting an error, but it still works.
The error is basically saying e.nativeEvent.source isn't valid on web.
By quickly commenting a few lines of node_modules/react-native-awesome-gallery/lib/module/index.js, I got rid of the error:
const defaultRenderImage = ({
item,
setImageDimensions
}) => {
return /*#__PURE__*/React.createElement(Image, {
onLoad: e => {
// const {
// height: h,
// width: w
// } = e.nativeEvent.source;
const h = 800;
const w = 500;
setImageDimensions({
height: h,
width: w
});
},
source: {
uri: item
},
resizeMode: "contain",
style: StyleSheet.absoluteFillObject
});
};
it's rough, it's just to prove that we could make this package work with web without too much trouble. I think this line needs to be changed:
https://github.com/pavelbabenko/react-native-awesome-gallery/blob/5ab264db201379a3b6aa2e7b65c8018dc46b05bd/src/index.tsx#L80
It's responsible for getting the size of the image being clicked. If I get around to it I'll make a PR, but I thought I'd just let people know.