Aayush Garg
Aayush Garg

Reputation: 1

Load website in mobile app using web view

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

class MyWeb extends Component { 
render() { 
return ( https://infinite.red' }} style={{ marginTop: 20 }} />
 ); 
} }

this is my code. I am trying to load a website using web view(react native) in mobile app.

Error: × Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of ExpoRootComponent

Upvotes: 0

Views: 230

Answers (1)

Akila Devinda
Akila Devinda

Reputation: 5502

Try this

import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { WebView } from 'react-native-webview';

// ...
class MyWebComponent extends Component {
  render() {
    return <WebView source={{ uri: 'https://infinite.red' }} style={{ marginTop: 20 }} />;
  }
}

You need to have a basic idea about the WebView package

API Documentation

Upvotes: 0

Related Questions