不变违规:requireNativeComponent:在 UIManager 中找不到“RNCWebView”

Sky*_*thi 9 react-native react-native-webview

朋友你好,我在将 react-native-webview 链接到我的项目后收到此错误

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)
Run Code Online (Sandbox Code Playgroud)

还有我的代码

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>' }}
      />
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

我的android中的错误图像

use*_*973 8

react-native link react-native-webview

检查:https : //github.com/react-native-community/react-native-webview/issues/140

  • 如果您使用 React Native 0.60+,则不再需要此操作,只需“cd ios”和“pod install”,也许重新启动 xCode,可能在 Xcode 中单击菜单中的“产品”&gt;“清理构建文件夹”,然后您就可以开始了 (2认同)

Rap*_*nel 7

使用 React Native 0.60+,无需向 podfile 添加任何内容。再试一次cd ios && pod install

如果没有帮助,请尝试重新启动模拟器并重建应用程序。重新启动 Xcode 也是一个好主意。

您可以选择清理 XCode 中的构建文件夹 在此处输入图片说明


Rub*_*ta2 5

尝试这些步骤。

  1. 删除 pods 文件夹和 podfile.lock
  2. npm 卸载react-native-webview
  3. npm 我反应本机webview
  4. 光盘
  5. 吊舱安装
  6. (npx) 反应本机运行 ios
  7. 重置缓存

  • 我忘记安装pod了兄弟 (2认同)