Skip to content

Commit

Permalink
[iOS] Replace UnimplementedView with UnimplementedNativeView
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw committed Sep 2, 2024
1 parent 6cfe51d commit 421881f
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 279 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#import <react/renderer/components/rncore/EventEmitters.h>
#import <react/renderer/components/rncore/Props.h>

#import "RCTFabricComponentsPlugins.h"

using namespace facebook::react;

@implementation RCTUnimplementedNativeComponentView {
Expand Down Expand Up @@ -56,4 +58,9 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
[super updateProps:props oldProps:oldProps];
}

Class<RCTComponentViewProtocol> RCTUnimplementedNativeViewCls(void)
{
return RCTUnimplementedNativeComponentView.class;
}

@end

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#import <React/RCTParagraphComponentView.h>
#import <React/RCTRootComponentView.h>
#import <React/RCTTextInputComponentView.h>
#import <React/RCTUnimplementedViewComponentView.h>
#import <React/RCTUnimplementedNativeComponentView.h>
#import <React/RCTViewComponentView.h>

#import <objc/runtime.h>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -158,18 +159,6 @@ - (BOOL)registerComponentIfPossible:(const std::string &)name
return YES;
}

// Fallback 4: use <UnimplementedView> if component doesn't exist.
auto flavor = std::make_shared<const std::string>(name);
auto componentName = ComponentName{flavor->c_str()};
auto componentHandle = reinterpret_cast<ComponentHandle>(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;
}
Expand Down
8 changes: 7 additions & 1 deletion packages/react-native/React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#import <react/config/ReactNativeConfig.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#import <react/renderer/components/rncore/ComponentDescriptors.h>
#import <react/renderer/components/text/BaseTextProps.h>
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
#import <react/renderer/scheduler/AsynchronousEventBeat.h>
Expand Down Expand Up @@ -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<ComponentDescriptorRegistry &>(*registry);
const ComponentDescriptorParameters &parametors = {eventDispatcher, contextContainer};
mutableRegistry.setFallbackComponentDescriptor(
std::make_shared<UnimplementedNativeViewComponentDescriptor>(parametors));
return registry;
};

auto runtimeExecutor = _runtimeExecutor;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 421881f

Please sign in to comment.