How to open links in Safari from React Native's WebView component

maha_funk

In the app, I'm using React Native's WebView component. If the user clicks on any links explicitly I would like it to open in Safari, instead of the WebView component being directed to that URL.

 <WebView
    source={{uri: 'https://some-url-here'}}
    style={{marginTop: 20}}
  />
while1

For IOS, you can use onShouldStartLoadWithRequest prop. The prop is called when webview is opening a new page. You can return false to stop loading and use React native Linking api to open url in safari.

Your onShouldStartLoadWithRequest could look like following:

onShouldStartLoadWithRequest={(navState)=>{
      Linking.openURL(navState.url)
      return false;
    }}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to open links in Safari from React Native's WebView component

From Dev

Open links in safari instead of inside webview

From Dev

Open links in safari instead of inside webview

From Dev

React Native- How to pass state from a component to it's parent

From Dev

How to open Safari View Controller from a Webview (swift)

From Dev

How can I force any links clicked within a WebView to open in Safari?

From Dev

React native , open a url in webview

From Dev

WKWebView open links from certain domain in safari

From Dev

Cannot open google maps in react native webview

From Dev

Cannot open google maps in react native webview

From Dev

Open UIWebView Links In Safari

From Dev

How to open a webview from imagebutton?

From Dev

Xamarin iOS C# Open Links in Safari from UIWebView

From Dev

ios App: how to open facebook link and ensure it's opened in safari and not in native app?

From Dev

How to open all links, besides some, in Safari with UIWebView?

From Dev

How to get onPress event from ScrollView Component in React Native

From Dev

How to get data from the redux store and use it in component in React Native

From Dev

How to pass back argument from child component on React Native

From Dev

How to include view to component from another file in react native?

From Dev

How to open Safari from a WebApp in iOS 7

From Dev

How to open magnet links from firefox with deluge

From Dev

How to open magnet links from firefox with deluge

From Dev

how to get links from chrome to open in firefox?

From Dev

How can I disallow WebView to open links on the browser in WinRT( target=_blank links )?

From Dev

I have a Array of links in list view how I can open these links in one webview

From Dev

How can i access react-native component from out of component?

From Dev

How to Open Google Maps from Webview click

From Dev

React Native - Edit other component's state

From Dev

Inject dynamic vars into React Native's WebView's injectedJavaScript string

Related Related

  1. 1

    How to open links in Safari from React Native's WebView component

  2. 2

    Open links in safari instead of inside webview

  3. 3

    Open links in safari instead of inside webview

  4. 4

    React Native- How to pass state from a component to it's parent

  5. 5

    How to open Safari View Controller from a Webview (swift)

  6. 6

    How can I force any links clicked within a WebView to open in Safari?

  7. 7

    React native , open a url in webview

  8. 8

    WKWebView open links from certain domain in safari

  9. 9

    Cannot open google maps in react native webview

  10. 10

    Cannot open google maps in react native webview

  11. 11

    Open UIWebView Links In Safari

  12. 12

    How to open a webview from imagebutton?

  13. 13

    Xamarin iOS C# Open Links in Safari from UIWebView

  14. 14

    ios App: how to open facebook link and ensure it's opened in safari and not in native app?

  15. 15

    How to open all links, besides some, in Safari with UIWebView?

  16. 16

    How to get onPress event from ScrollView Component in React Native

  17. 17

    How to get data from the redux store and use it in component in React Native

  18. 18

    How to pass back argument from child component on React Native

  19. 19

    How to include view to component from another file in react native?

  20. 20

    How to open Safari from a WebApp in iOS 7

  21. 21

    How to open magnet links from firefox with deluge

  22. 22

    How to open magnet links from firefox with deluge

  23. 23

    how to get links from chrome to open in firefox?

  24. 24

    How can I disallow WebView to open links on the browser in WinRT( target=_blank links )?

  25. 25

    I have a Array of links in list view how I can open these links in one webview

  26. 26

    How can i access react-native component from out of component?

  27. 27

    How to Open Google Maps from Webview click

  28. 28

    React Native - Edit other component's state

  29. 29

    Inject dynamic vars into React Native's WebView's injectedJavaScript string

HotTag

Archive