Skip to content

Commit 94dfc15

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: Temporary workaround to enable commands in Fabric
Summary: This is a temporary workaround that we need only temporary and will get rid of soon. Reviewed By: mdvacca Differential Revision: D15501203 fbshipit-source-id: cec4891b6a185ea9e39f50bfedf9e1dae8993b66
1 parent d88e470 commit 94dfc15

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ NS_ASSUME_NONNULL_BEGIN
7979
- (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask NS_REQUIRES_SUPER;
8080
- (void)prepareForRecycle NS_REQUIRES_SUPER;
8181

82+
/*
83+
* This is a fragment of temporary workaround that we need only temporary and will get rid of soon.
84+
*/
85+
- (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN;
86+
8287
@end
8388

8489
NS_ASSUME_NONNULL_END

React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,4 +564,9 @@ - (SharedTouchEventEmitter)touchEventEmitterAtPoint:(CGPoint)point
564564
return _eventEmitter;
565565
}
566566

567+
- (NSString *)componentViewName_DO_NOT_USE_THIS_IS_BROKEN
568+
{
569+
return RCTNSStringFromString([[self class] componentDescriptorProvider].name);
570+
}
571+
567572
@end

React/Modules/RCTUIManager.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,25 @@ - (void)synchronouslyUpdateViewOnUIThread:(NSNumber *)reactTag
10651065
{
10661066
RCTShadowView *shadowView = _shadowViewRegistry[reactTag];
10671067
RCTComponentData *componentData = _componentDataByName[shadowView.viewName];
1068+
1069+
// Achtung! Achtung!
1070+
// This is a remarkably hacky and ugly workaround.
1071+
// We need this only temporary for some testing. We need this hack until Fabric fully implements command-execution pipeline.
1072+
// This does not affect non-Fabric apps.
1073+
#pragma clang diagnostic push
1074+
#pragma clang diagnostic ignored "-Wundeclared-selector"
1075+
if (!componentData) {
1076+
__block UIView *view;
1077+
RCTUnsafeExecuteOnMainQueueSync(^{
1078+
view = self->_viewRegistry[reactTag];
1079+
});
1080+
if ([view respondsToSelector:@selector(componentViewName_DO_NOT_USE_THIS_IS_BROKEN)]) {
1081+
NSString *name = [view performSelector:@selector(componentViewName_DO_NOT_USE_THIS_IS_BROKEN)];
1082+
componentData = _componentDataByName[[NSString stringWithFormat:@"RCT%@", name]];
1083+
}
1084+
}
1085+
#pragma clang diagnostic pop
1086+
10681087
Class managerClass = componentData.managerClass;
10691088
RCTModuleData *moduleData = [_bridge moduleDataForName:RCTBridgeModuleNameForClass(managerClass)];
10701089
id<RCTBridgeMethod> method = moduleData.methods[commandID];

0 commit comments

Comments
 (0)