Skip to content

Web compatibility#93

Description

@JPFrancoia

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: #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:

const { height: h, width: w } = e.nativeEvent.source;

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions