1

I'm trying to call UI component's method from Javascript. I follow official React Native documentation but I got this error:

error: method does not override or implement a method from a supertype

My WidgetManager.java

public class WidgetManager extends SimpleViewManager<LinearLayout> {

  public static final String REACT_CLASS = "WidgetManager";

  public WidgetManager(ReactApplicationContext reactContext) {}

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

  @Override
  public WidgetLayoutView createViewInstance(ThemedReactContext context) {
    return new WidgetLayoutView(context);
  }

  @Override
  public void receiveCommand(
    @NonNull WidgetLayoutView view,
    String commandId,
    @Nullable ReadableArray args
  ) {
    Log.v("ReactNative", commandId);
    switch (commandId) {
      case "addWidget":
        {
          view.addWidget(args.getInt(0));
          return;
        }
      default:
        throw new IllegalArgumentException(
          String.format(
            "Unsupported command %d received by %s.",
            commandId,
            getClass().getSimpleName()
          )
        );
    }
  }
}

I dispatch command via dispatchViewManagerCommand method.

UIManager.dispatchViewManagerCommand(
        findNodeHandle(WidgetManagerRef.current),
        'addWidget',
        undefined,
      );

What am I doing wrong?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Kevin Bui
  • 524
  • 3
  • 10

0 Answers0