diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm index fe4c9f6a65b142..ef48fa1371f1d5 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedComponent/RCTUnimplementedNativeComponentView.mm @@ -11,6 +11,8 @@ #import #import +#import "RCTFabricComponentsPlugins.h" + using namespace facebook::react; @implementation RCTUnimplementedNativeComponentView { @@ -56,4 +58,9 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & [super updateProps:props oldProps:oldProps]; } +Class RCTUnimplementedNativeViewCls(void) +{ + return RCTUnimplementedNativeComponentView.class; +} + @end diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.h b/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.h deleted file mode 100644 index 8c2c82a3f0c5c8..00000000000000 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import - -NS_ASSUME_NONNULL_BEGIN - -/* - * UIView class for all kinds of components. - */ -@interface RCTUnimplementedViewComponentView : RCTViewComponentView - -@end - -NS_ASSUME_NONNULL_END diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm deleted file mode 100644 index b5185677875a13..00000000000000 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/UnimplementedView/RCTUnimplementedViewComponentView.mm +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "RCTUnimplementedViewComponentView.h" - -#import -#import -#import - -#import -#import - -#import - -#import "RCTFabricComponentsPlugins.h" - -using namespace facebook::react; - -@implementation RCTUnimplementedViewComponentView { - UILabel *_label; -} - -- (instancetype)initWithFrame:(CGRect)frame -{ - if (self = [super initWithFrame:frame]) { - _props = UnimplementedViewShadowNode::defaultSharedProps(); - - _label = [[UILabel alloc] initWithFrame:self.bounds]; - _label.backgroundColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:0.3]; - _label.lineBreakMode = NSLineBreakByCharWrapping; - _label.numberOfLines = 0; - _label.textAlignment = NSTextAlignmentCenter; - _label.textColor = [UIColor whiteColor]; - _label.allowsDefaultTighteningForTruncation = YES; - _label.adjustsFontSizeToFitWidth = YES; - - self.contentView = _label; - } - - return self; -} - -#pragma mark - RCTComponentViewProtocol - -+ (ComponentDescriptorProvider)componentDescriptorProvider -{ - return concreteComponentDescriptorProvider(); -} - -- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps -{ - const auto &oldUnimplementedViewProps = static_cast(*_props); - const auto &newUnimplementedViewProps = static_cast(*props); - - if (oldUnimplementedViewProps.getComponentName() != newUnimplementedViewProps.getComponentName()) { - _label.text = - [NSString stringWithFormat:@"Unimplemented component: <%s>", newUnimplementedViewProps.getComponentName()]; - } - - [super updateProps:props oldProps:oldProps]; -} - -@end - -Class RCTUnimplementedNativeViewCls(void) -{ - return RCTUnimplementedViewComponentView.class; -} diff --git a/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm b/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm index 97bf3b3b42cfd7..eb7d31c3b4575e 100644 --- a/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm +++ b/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm @@ -36,7 +36,7 @@ #import #import #import -#import +#import #import #import @@ -75,6 +75,7 @@ + (RCTComponentViewFactory *)currentComponentViewFactory componentViewFactory = [RCTComponentViewFactory new]; [componentViewFactory registerComponentViewClass:[RCTRootComponentView class]]; [componentViewFactory registerComponentViewClass:[RCTParagraphComponentView class]]; + [componentViewFactory registerComponentViewClass:[RCTUnimplementedNativeComponentView class]]; componentViewFactory->_providerRegistry.setComponentDescriptorProviderRequest( [](ComponentName requestedComponentName) { @@ -158,18 +159,6 @@ - (BOOL)registerComponentIfPossible:(const std::string &)name return YES; } - // Fallback 4: use if component doesn't exist. - auto flavor = std::make_shared(name); - auto componentName = ComponentName{flavor->c_str()}; - auto componentHandle = reinterpret_cast(componentName); - auto constructor = [RCTUnimplementedViewComponentView componentDescriptorProvider].constructor; - - [self _addDescriptorToProviderRegistry:ComponentDescriptorProvider{ - componentHandle, componentName, flavor, constructor}]; - - _componentViewClasses[componentHandle] = - [self _componentViewClassDescriptorFromClass:[RCTUnimplementedViewComponentView class]]; - // No matching class exists for `name`. return NO; } diff --git a/packages/react-native/React/Fabric/RCTSurfacePresenter.mm b/packages/react-native/React/Fabric/RCTSurfacePresenter.mm index 5d6f02e91430d8..53c24fa8a48dbe 100644 --- a/packages/react-native/React/Fabric/RCTSurfacePresenter.mm +++ b/packages/react-native/React/Fabric/RCTSurfacePresenter.mm @@ -29,6 +29,7 @@ #import #import #import +#import #import #import #import @@ -240,8 +241,13 @@ - (RCTScheduler *)_createScheduler auto componentRegistryFactory = [factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)]( const EventDispatcher::Weak &eventDispatcher, const ContextContainer::Shared &contextContainer) { - return [(RCTComponentViewFactory *)unwrapManagedObject(factory) + auto registry = [(RCTComponentViewFactory *)unwrapManagedObject(factory) createComponentDescriptorRegistryWithParameters:{eventDispatcher, contextContainer}]; + auto &mutableRegistry = const_cast(*registry); + const ComponentDescriptorParameters ¶metors = {eventDispatcher, contextContainer}; + mutableRegistry.setFallbackComponentDescriptor( + std::make_shared(parametors)); + return registry; }; auto runtimeExecutor = _runtimeExecutor; diff --git a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp deleted file mode 100644 index 7b42990f7c414b..00000000000000 --- a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "UnimplementedViewComponentDescriptor.h" - -namespace facebook::react { - -ComponentHandle UnimplementedViewComponentDescriptor::getComponentHandle() - const { - return reinterpret_cast(getComponentName()); -} - -ComponentName UnimplementedViewComponentDescriptor::getComponentName() const { - return static_cast(flavor_.get())->c_str(); -} - -Props::Shared UnimplementedViewComponentDescriptor::cloneProps( - const PropsParserContext& context, - const Props::Shared& props, - RawProps rawProps) const { - auto clonedProps = - ConcreteComponentDescriptor::cloneProps( - context, props, std::move(rawProps)); - - // We have to clone `Props` object one more time to make sure that we have - // an unshared (and non-`const`) copy of it which we can mutate. - RawProps emptyRawProps{}; - emptyRawProps.parse(rawPropsParser_); - auto unimplementedViewProps = std::make_shared( - context, - static_cast(*clonedProps), - std::move(emptyRawProps)); - - unimplementedViewProps->setComponentName(getComponentName()); - return unimplementedViewProps; -}; - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h deleted file mode 100644 index e73046568de792..00000000000000 --- a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include -#include - -namespace facebook::react { - -/* - * Descriptor for component. - */ -class UnimplementedViewComponentDescriptor final - : public ConcreteComponentDescriptor { - public: - using ConcreteComponentDescriptor::ConcreteComponentDescriptor; - - /* - * Returns `name` and `handle` based on a `flavor`, not on static data from - * `UnimplementedViewShadowNode`. - */ - ComponentHandle getComponentHandle() const override; - ComponentName getComponentName() const override; - - /* - * In addition to base implementation, stores a component name inside cloned - * `Props` object. - */ - Props::Shared cloneProps( - const PropsParserContext& context, - const Props::Shared& props, - RawProps rawProps) const override; -}; - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.cpp b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.cpp deleted file mode 100644 index 10686f9c63917c..00000000000000 --- a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include - -namespace facebook::react { - -void UnimplementedViewProps::setComponentName(ComponentName componentName) { - componentName_ = componentName; -} - -ComponentName UnimplementedViewProps::getComponentName() const { - return componentName_; -} - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.h b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.h deleted file mode 100644 index 9daf3bc283cd1c..00000000000000 --- a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewProps.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include - -namespace facebook::react { - -/* - * It's a normal `ViewProps` with additional information about the component - * name which is being updated manually in `ComponentDescriptor`. - */ -class UnimplementedViewProps final : public ViewProps { - public: - using ViewProps::ViewProps; - - /* - * Should be called from a `ComponentDescriptor` to store information about - * the name of a particular component. - */ - void setComponentName(ComponentName componentName); - ComponentName getComponentName() const; - - private: - mutable ComponentName componentName_{}; -}; - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.cpp deleted file mode 100644 index a30a006cd4153f..00000000000000 --- a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "UnimplementedViewShadowNode.h" - -namespace facebook::react { - -const char UnimplementedViewComponentName[] = "UnimplementedView"; - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.h b/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.h deleted file mode 100644 index 405c81e647fd03..00000000000000 --- a/packages/react-native/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewShadowNode.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include - -namespace facebook::react { - -extern const char UnimplementedViewComponentName[]; - -using UnimplementedViewShadowNode = ConcreteViewShadowNode< - UnimplementedViewComponentName, - UnimplementedViewProps>; - -} // namespace facebook::react