1

I am creating my first React-Native project and I intend to add a link in my views.

 <TouchableOpacity
   style={redditMain} > 
     <Image 
      source={ this.image }
       style={img} />
     <Text style={RedditList}>{this.text}</Text>
      </TouchableOpacity>

I went through the React-Native docs which I am thinking talks about how we can achieve this and In that they have wrote this in their documentation

To start the corresponding activity for a link (web URL, email, contact etc.), call

Linking.openURL(url).catch(err => console.error('An error occurred', err));

So I changed my code accordingly to this

  <TouchableOpacity
   onPress={() => {Linking.openURL('http://www.google.com/')}}
   style={redditMain} > 
    <Image 
     source={ this.image }
     style={img}
       /> 
     <Text style={RedditList}>{this.text}</Text>
     </TouchableOpacity>

So whenever I click it starts throwing the following error

Linking is not defined

[Question:] How I can fix it?

1 Answer 1

2
import { Linking } from 'react-native';
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.