Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing data through React-Navigation Issue #106

Open
rizwanellahi opened this issue Jan 12, 2020 · 6 comments
Open

Passing data through React-Navigation Issue #106

rizwanellahi opened this issue Jan 12, 2020 · 6 comments

Comments

@rizwanellahi
Copy link

rizwanellahi commented Jan 12, 2020

Passing Data Using React-Navigation. Only grid images showing but the image preview throwing android error.

render() {
    const photos = this.props.navigation.getParam('getPhotos').acf.gallery;
    const imageSize = Dimensions.get('window').width / 3;
    const imageStyle = {
      width: imageSize,
      height: imageSize,
    };

    return (
      <View style={styles.container}>
        <PhotoView
          visible={this.state.visible}
          data={photos}
          hideStatusBar={true}
          hideCloseButton={true}
          hideShareButton={true}
          initial={this.state.initial}
          onDismiss={() => {
            this.setState({visible: false});
          }}
          onChange={data => {
            this.setState({initial: data.index});
          }}
        />
        <ScrollView showsVerticalScrollIndicator={false}>
          <View style={styles.photoContainer}>
            {photos.map((cat, index) => (
              <TouchableOpacity
                key={index.id}
                style={[imageStyle, {}]}
                ref={r => (this.r = r)}
                onPress={() =>
                  this.setState({visible: true, initial: index.id})
                }>
                <Image style={imageStyle} source={{uri: cat.url}} />
              </TouchableOpacity>
            ))}
          </View>
        </ScrollView>
      </View>
    );
  }

"react-native": "0.61.5",
"@merryjs/photo-viewer": "^3.1.2",

Android Error

Attempt to invoke interface method 'java.lang.string com.facebook.react.bridge.readablemap.getstring on a null object reference

@BANG88
Copy link
Member

BANG88 commented Jan 16, 2020

Please check your data at first maybe there has a null reference. I guess

@rizwanellahi
Copy link
Author

Images thumbnails are showing <Image style={imageStyle} source={{uri: cat.url}} /> In image source we are converting the image url to uri. But in data={photos} how image will be convert into uri.

That's why whenever i tap on the image for preview throwing this error:

Attempt to invoke interface method 'java.lang.string com.facebook.react.bridge.readablemap.getstring on a null object reference

@BANG88
Copy link
Member

BANG88 commented Jan 16, 2020

@Rizwanilahi Could you please checkout the examples and then re-check your data. I think this should not an issue with this pkg.

@BANG88
Copy link
Member

BANG88 commented Jan 16, 2020

@rizwanellahi
Copy link
Author

@BANG88 The example is working fine.

const photos = [
  {
    source: {
      uri:
        "https://images.pexels.com/photos/82072/cat-82072.jpeg?w=1260&h=750&auto=compress&cs=tinysrgb"
    }
  }
];

The image source Uri is already defined here. In my case, I am using API receiving data. const photos = this.props.navigation.getParam('getPhotos').acf.gallery;

@BANG88
Copy link
Member

BANG88 commented Jan 16, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants