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

react-native-web support

Open Powersource opened this issue 5 years ago • 8 comments

Would be nice. Right now I'm getting this error because it's missing a web implementation for ImageItem

ERROR in ./node_modules/react-native-image-viewing/dist/ImageViewing.js
Module not found: Error: Can't resolve './components/ImageItem/ImageItem' in '/home/me/prj/ssb/manyverse/node_modules/react-native-image-viewing/dist'
 @ ./node_modules/react-native-image-viewing/dist/ImageViewing.js 1:1047-1090
 @ ./node_modules/react-native-image-viewing/dist/index.js
 @ ./lib/frontend/components/ZoomableImage.js
 @ ./lib/frontend/components/Markdown.js
 @ ./lib/frontend/components/messages/AboutMessage.js
 @ ./lib/frontend/components/messages/Message.js
 @ ./lib/frontend/components/FullThread.js
 @ ./lib/frontend/screens/thread/view.js
 @ ./lib/desktop/index.js

Powersource avatar Jan 15 '21 17:01 Powersource

I got the same problem on web

/Users/X/XX/XXX/node_modules/react-native-image-viewing/dist/ImageViewing.js
Module not found: Can't resolve './components/ImageItem/ImageItem' in '/Users/X/XX/XXX/node_modules/react-native-image-viewing/dist'

Please help!

likeSo avatar Aug 31 '21 13:08 likeSo

Just to check if supporting react-native-web is easy, I did the following changes:

  • Renamed node_modules/react-native-image-viewing/dist/components/ImageItem/ImageItem.android.js to ImageItem.js
  • In node_modules/react-native-image-viewing/dist/hooks/useImageDimensions.js I changed Image.getSizeWithHeaders(source.uri, source.headers, to Image.getSize(source.uri,

And it worked! In other words, supporting react-native-web in this repo is not too hard. I can make a PR, but wanted to inform about this already.

staltz avatar Dec 09 '21 14:12 staltz