React Native TypeError:无法读取null的属性“isFileUploadSupported”

mgdq6dx1  于 2023-04-22  发布在  React
关注(0)|答案(1)|浏览(286)

我试图在我的React-Native应用程序中使用react-native-webview渲染HTML片段,我也尝试了react-native-render-html,但在这个CSS中没有那么多工作。
这是我的错误堆栈

ERROR  TypeError: Cannot read property 'isFileUploadSupported' of null, js engine: hermes 
at App (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.dbc&modulesOnly=false&runModule=true:93600:36)
at RCTView
at View
at RCTView
at View
at AppContainer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.dbc&modulesOnly=false&runModule=true:85300:36)
at DBC(RootComponent) (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.dbc&modulesOnly=false&runModule=true:89907:28)
 ERROR  Error: Requiring module "node_modules/react-native-webview/index.js", which threw an exception: TypeError: Cannot read property 'isFileUploadSupported' of null, js engine: hermes 
at App (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.dbc&modulesOnly=false&runModule=true:93600:36)
at RCTView
at View
at RCTView
at View
at AppContainer (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.dbc&modulesOnly=false&runModule=true:85300:36)
at DBC(RootComponent) (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.dbc&modulesOnly=false&runModule=true:89907:28)
 ERROR  TypeError: Cannot read property 'WebView' of undefined
This error is located at:
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in DBC(RootComponent), js engine: hermes

这是我的代码

import {SafeAreaView, ScrollView, useWindowDimensions} from 'react-native';
import {WebView} from 'react-native-webview';
import {getTemplate} from './template';

export default class App extends Component {
  render() {
    const template = getTemplate();
    const source = {
      html: template,
    };
    return (
      <SafeAreaView>
        <ScrollView>
          <ScrollView horizontal={true}>
            <WebView
              ref={r => (this.webref = r)}
              originWhitelist={['*']}
              source={source}
            />
          </ScrollView>
        </ScrollView>
      </SafeAreaView>
    );
  }
}
bprjcwpo

bprjcwpo1#

如此处所述,尝试重新安装react-native-webview
Yarn:

yarn add react-native-webview

npm:

npm i react-native-webview

相关问题