'Invariant Violation: requireNativeComponent: "RNCWebView" was not found in the UIManager
Hello friends i got this error after linking react-native-webview to my project
Invariant Violation: requireNativeComponent: "RNCWebView" was not found in the UIManager.
This error is located at:
in RNCWebView (at WebView.android.js:250)
in RCTView (at WebView.android.js:253)
in WebView (at App.js:7)
in App (at renderApplication.js:45)
in RCTView (at AppContainer.js:109)
in RCTView (at AppContainer.js:135)
in AppContainer (at renderApplication.js:39)
And there is my code
import React, { Component } from 'react';
import { WebView } from 'react-native-webview';
export default class App extends Component {
render() {
return (
<WebView
originWhitelist={['*']}
source={{ html: '<h1>Hello world</h1>' }}
/>
);
}
}
Solution 1:[1]
run react-native link react-native-webview
check: https://github.com/react-native-community/react-native-webview/issues/140
Solution 2:[2]
With React Native 0.60+, no need to add anything to the podfile.
Try again cd ios && pod install
If it doesn't help, try restarting the simulator and rebuilding the app. Restarting Xcode is also a good idea.
Solution 3:[3]
Try these steps.
- Delete pods folder and podfile.lock
- npm uninstall react-native-webview
- npm i react-native-webview
- cd ios
- pod install
- (npx) react-native run-ios
- Reset cache
Solution 4:[4]
I had the same issue. Try Add this line to your podfile :-
pod 'react-native-webview', :path => PROJECT_PATH + 'react-native-webview'
then go to ios folder cd ios and install pods pod install
It has resolved this problem for me.
Solution 5:[5]
my solution for this problem was the following:
Android
1 add this in your android/settings.gradle
include ':react-native-webview'
project(':react-native-webview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-webview/android')
2 add this in your android/app/build.gradle
dependencies {
implementation project(':react-native-webview')
....
3 in your MainApplication.java:
import com.reactnativecommunity.webview.RNCWebViewPackage;//add this import
....
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNCWebViewPackage(),//add line
....
IOS
1 add the following line in your ios/Podfile and then open your terminal, go to your project ios folder and run pod install
...
pod 'react-native-webview', :path => '../node_modules/react-native-webview'
...
Solution 6:[6]
Make sure you did:
npx pod-installnpx react-native run-ios
After installing the package you. need to update pods and then run the project again.
Solution 7:[7]
I had the same issue before , I tried this:
pod 'react-native-webview', :path => PROJECT_PATH + 'react-native-webview'
Solution 8:[8]
I update webView to the latest (11.18.1) and it was fixed without any additional linking steps.
Solution 9:[9]
I have done below steps:
1. cd ios
2. rm Podfile.lock
3. pod install
This installed the missing library i.e. react-native-webview and added below line to Podfile file.
pod 'react-native-webview', :path => '../node_modules/react-native-webview'
environment which I am working on:
"react": "16.9.0",
"react-native": "0.61.5"
Solution 10:[10]
Follow these simple steps worked for me:
- Rebuild the App. Run:
npx react-native run-android
- Run:
react-native link react-native-webview
- Check if
RNCWebViewPackageis imported inMainApplication.javafile, which looks something like this:
import com.reactnativecommunity.webview.RNCWebViewPackage;
Note: I'm using [email protected].
Solution 11:[11]
There is no need to add anything or use the link for React Native 0.60+. In my case, which was android, I simply build the project again using: $ npm run android
Solution 12:[12]
Have you tried to link manually?
Go to ../node_modules/react-native-webview/ios and drag and drop the RNCWebView.xcodeproj to Libraries folder on Xcode, right after, Go to Build Phases tab (on Xcode) in the section "Link binary With libraries" add the libRNCWebView.a (inside Libraries/RNCWebView.xcodeproj/Products). Try to build and run
Solution 13:[13]
try to re-build your project after installation and link of webview package (npx react-native run-android)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow

