registerComponent2 function

ReactDartComponentFactoryProxy2<Component2> registerComponent2(
  1. Component2 dartComponentFactory(), {
  2. bool isWrapper = false,
  3. ReactDartComponentFactoryProxy<Component>? parentType,
  4. UiFactory<UiProps>? builderFactory,
  5. Type? componentClass,
  6. Iterable<String> skipMethods = const ['getDerivedStateFromError', 'componentDidCatch'],
})

Helper function that wraps react.registerComponent2, and allows attachment of additional component factory metadata.

  • isWrapper: whether the component clones or passes through its children and needs to be treated as if it were the wrapped component.

  • builderFactory/componentClass: the UiFactory and UiComponent2 members to be potentially used as types for isComponentOfType/getComponentFactory.

  • displayName: (DEPRECATED) the name of the component for use when debugging.

Implementation

ReactDartComponentFactoryProxy2 registerComponent2(react.Component2 Function() dartComponentFactory, {
    bool isWrapper = false,
    // This must remain typed in a way that both UiComponent and UiComponent2 classes can be passed as the `subtypeOf` value.
    // ignore: deprecated_member_use
    ReactDartComponentFactoryProxy? parentType,
    UiFactory? builderFactory,
    Type? componentClass,
    Iterable<String> skipMethods = const ['getDerivedStateFromError', 'componentDidCatch'],
}) {
  final reactComponentFactory = react.registerComponent2(
    dartComponentFactory,
    skipMethods: skipMethods,
    bridgeFactory: UiComponent2BridgeImpl.bridgeFactory,
  );

  registerComponentTypeAlias(reactComponentFactory, builderFactory);
  registerComponentTypeAlias(reactComponentFactory, componentClass);

  setComponentTypeMeta(reactComponentFactory.type, isWrapper: isWrapper, parentType: parentType?.type);

  return reactComponentFactory;
}