O'Reilly logo

React Native Cookbook by Crysfel Villa, Stan Bershadskiy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a WebView to open external websites

For many apps, it's required that it can open external links, whether its to show a third-party website, your online help, or the terms and conditions of your app.

In this recipe, we will see how to open a WebView by clicking on a button in our app and dynamically setting the URL value.

How to do it...

  1. Similar to our previous recipes, we will start by creating a new app using the React Native CLI, and we will name it Browser. After the new project has been created, open the index.ios.js and index.android.js files; we need to add the following code to bootstrap our app:
            import React from 'react';        import MainApp from './src/MainApp';        import { AppRegistry } from 'react-native';        AppRegistry.registerComponent('Browser', ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required