Skip to content

Commit cd5f0bd

Browse files
sherginfacebook-github-bot
authored andcommitted
Fabric: Stopping creating ShadowView instances for non-View ShadowNodes
Summary: Apparently, the previous behavior brings more problems than some *possible-in-the-future* features and flexibility. The new model allows us to easily implement "nested text" feature. (We temporary hope the old behavious for Android only for compatibility reasons.) Reviewed By: mdvacca Differential Revision: D13176277 fbshipit-source-id: 01f7bfb3c2e70cc89d76ecb78add016ee91cbd63
1 parent e581977 commit cd5f0bd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

React/Fabric/RCTScheduler.mm

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ void schedulerDidFinishTransaction(Tag rootTag, const ShadowViewMutationList &mu
2828
}
2929

3030
void schedulerDidRequestPreliminaryViewAllocation(SurfaceId surfaceId, ComponentName componentName, bool isLayoutable, ComponentHandle componentHandle) override {
31+
if (!isLayoutable) {
32+
return;
33+
}
34+
3135
RCTScheduler *scheduler = (__bridge RCTScheduler *)scheduler_;
3236
[scheduler.delegate schedulerOptimisticallyCreateComponentViewWithComponentHandle:componentHandle];
3337
}

ReactCommon/fabric/uimanager/Differentiator.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,17 @@ static void sliceChildShadowNodeViewPairsRecursively(
2020

2121
const auto layoutableShadowNode =
2222
dynamic_cast<const LayoutableShadowNode *>(childShadowNode.get());
23+
#ifndef ANDROID
24+
// New approach (iOS):
25+
// Non-view components are treated as layout-only views (they aren't
26+
// represented as `ShadowView`s).
27+
if (!layoutableShadowNode || layoutableShadowNode->isLayoutOnly()) {
28+
#else
29+
// Previous approach (Android):
30+
// Non-view components are treated as normal views with an empty layout
31+
// (they are represented as `ShadowView`s).
2332
if (layoutableShadowNode && layoutableShadowNode->isLayoutOnly()) {
33+
#endif
2434
sliceChildShadowNodeViewPairsRecursively(
2535
pairList,
2636
layoutOffset + shadowView.layoutMetrics.frame.origin,

0 commit comments

Comments
 (0)