Théo Lavaux
Théo Lavaux

Reputation: 1454

Open webview on top of a React Native App

I would like to open a link "in-app" without leaving a React Native app. The idea would be to open a webview on top of the application when clicking the link like Gmail or Messenger do.

Is there a way to do this in React Native?

Upvotes: 0

Views: 1384

Answers (2)

Hasan Al-Natour
Hasan Al-Natour

Reputation: 2066

this is very simple

import React, {Component} from 'react';
import {WebView} from 'react-native';

class MyWeb extends Component {
  render() {
    return (
      <WebView
        source={{uri: 'https://github.com/facebook/react-native'}}
        style={{marginTop: 20}}
      />
    );
  }
}

Upvotes: 1

arjayosma
arjayosma

Reputation: 550

Yes. You can create a new screen, with a rendered WebView inside.

You may refer to this link: https://docs.expo.io/versions/latest/react-native/webview/#__next

In your router, (if you're using react-navigation) you can just use "modal" for your navigation's mode.

Upvotes: 1

Related Questions