【发布时间】:2018-06-09 12:28:49
【问题描述】:
我正在尝试加载自定义 Android WebView 以便能够使用 html 文件输入上传文件(默认情况下,Android webview 不会与输入文件一起使用)。 Im using this code,唯一的区别是我使用的是expo kit,所以我的MainApplication.java是不同的(默认继承另一个类):
public class MainApplication extends MultiDexApplication {
// Needed for `react-native link`
public List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new CustomWebViewPackage()
);
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
git 代码所做的基本上是覆盖默认的 react native webview 以使其使用 Android 中的 CustomWebView.java,使用 requireNativeComponent 和此代码 (this is on CustomWebView.android.js):
var RCTWebView = requireNativeComponent('CustomWebView', WebView, {
nativeOnly: {
messagingEnabled: PropTypes.bool,
},
});
但是当我使用 exp start 运行应用程序并导航到具有 CustomWebView 的屏幕时,我收到此错误:
总结问题是我的自定义原生组件没有被 React Native 读取。有人可以帮帮我吗?
【问题讨论】:
标签: android reactjs react-native react-native-android expo