0

I am passing parameters from one page to another page. I am also passing a link (http://wwww.yahoo.com) to the resulting page along with other parameters. Below is the code of my source page:

 <View style={styles.searchButton}>
            <Button style={styles.searchButton}
               title="Go to Details"
                 onPress={() => {
                  this.props.navigation.navigate('SearchSer', {
                    itemId: services[0].ser,
                  otherParam: services[0],

In the below code, I am trying to put the link in TouchableOpacity by reading the parameter. When I tried to open the link, I get an error saying "JSON parse error". Below is my code and screen shot of the error:

<View>
  <Text style={styles.Address1}> {JSON.stringify(otherParam["Phone"])}</Text>
                 <TouchableOpacity  onPress={() => Linking.openURL(JSON.parse(JSON.stringify(otherParam["destURL"]))) }>
                    <Text style={styles.underLineText}>Distance and Directions</Text>
                </TouchableOpacity>
        </View>

enter image description here

destURL is http://www.yahoo.com and it is coming from my JSON file. any help will be highly appreciated.

Anjali
  • 2,540
  • 7
  • 37
  • 77
  • There is no problem with the code, it seems the params you're getting is undefined, try logging, or can you post the object that you get `otherParam["destURL"]` ? – Pritish Vaidya May 09 '18 at 11:32
  • Yes, that was the issue. I figured out later when no one posted the answer for a while. – Anjali May 09 '18 at 16:25

0 Answers0