Error : WebView has been removed from react native

Viewed 1245

I built new React Native project yesterday using react-native-cli. But when running the project with my android phone, I got this error in red screen.

Invariant Violation: WebView has been removed from React Native. It can now be installed and imported from 'react-native-webview' instead of 'react-native'. See 'https://github.com/react-native-community/react-native-webview'.

scri

1 Answers

For your scenario Old WebView is now deprecated for better performance and to reduce package sizes. You can find more information about this by here

Solution

Install new WebView Package using this command

npm install --save react-native-webview 

You can find more information regarding package installation from here

After installing above mentioned package now remove old imports and re-import WebView like this

import { WebView, } from 'react-native'; //Remove this from your imports

import { WebView } from 'react-native-webview'; //Add this to your imports
Related