mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-27 19:25:11 +08:00
Fabric: Fixed issue where root shadow node does not layout itself
Summary: Conceptually, it always must be node owner's responsibility, but for the root node, we have to make an exception because there is no another parent node and there is no another component which has access to YogaNode. Reviewed By: fkgozali Differential Revision: D7958251 fbshipit-source-id: 0bdaea87adbd323c758bc3c28f325be615aa90f3
This commit is contained in:
committed by
Facebook Github Bot
parent
274c1757e6
commit
10c5368c37
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "RootShadowNode.h"
|
||||
#include "conversions.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
@@ -17,6 +18,11 @@ ComponentName RootShadowNode::getComponentName() const {
|
||||
void RootShadowNode::layout() {
|
||||
ensureUnsealed();
|
||||
layout(getProps()->layoutContext);
|
||||
|
||||
// This is the rare place where shadow node must layout (set `layoutMetrics`)
|
||||
// itself because there is no a parent node which usually should do it.
|
||||
YGNode *yogaNode = const_cast<YGNode *>(yogaNode_.get());
|
||||
setLayoutMetrics(layoutMetricsFromYogaNode(*yogaNode));
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
Reference in New Issue
Block a user