Skip to content

Invariant Violation: requireNativeComponent:"***" was not found in theUIManager #28836

@liyuewen

Description

@liyuewen

在MyWebViewManager.java中
`
public class MyWebViewManager extends SimpleViewManager {

public static final String REACT_CLASS = "MyWebViewManager";

@OverRide
public String getName() {
return REACT_CLASS;
}

@OverRide
protected TextView createViewInstance(ThemedReactContext reactContext) {
TextView tv = new TextView(reactContext);
tv.setText("hello from android !");
return tv;
}
}
`

在MyWebViewPackage.java中
`
public class MyWebViewPackage implements ReactPackage {

@OverRide
public List createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}

@OverRide
public List createNativeModules(
ReactApplicationContext reactContext) {
List modules = new ArrayList<>();

  modules.add(new MyWebViewManager());

  return modules;

}

}
`

在ScannerView.js中
`
import React, { Component } from 'react'
import { View, requireNativeComponent } from 'react-native'

const MyWebViewManager = requireNativeComponent('MyWebViewManager', ScannerView);

class ScannerView extends Component {
render() {
return
}
}

ScannerView.propTypes = {
...View.propTypes
}

export default ScannerView
`
在模拟器中发生错误
Invariant Violation: requireNativeComponent:"MyWebViewManager" was not found in theUIManager.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionIssues where the author has responded to feedback.Needs: Environment InfoPlease run `react-native info` and edit your issue with that command's output.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions