Skip to content

Commit f6e06db

Browse files
committed
Reuse layout context
1 parent 0a5c773 commit f6e06db

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

apple/MarkdownTextInputDecoratorShadowNode.mm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
extern const char MarkdownTextInputDecoratorViewComponentName[] =
1616
"MarkdownTextInputDecoratorView";
1717

18+
thread_local LayoutContext decoratorLayoutContext{.fontSizeMultiplier =
19+
RCTFontSizeMultiplier()};
20+
1821
void MarkdownTextInputDecoratorShadowNode::initialize() {
1922
// Setting display: contents style results in ForceFlattenView trait being set
2023
// on the shadow node. This trait causes the node not to have a host view. By
@@ -93,6 +96,7 @@
9396

9497
void MarkdownTextInputDecoratorShadowNode::layout(LayoutContext layoutContext) {
9598
YogaLayoutableShadowNode::layout(layoutContext);
99+
decoratorLayoutContext = layoutContext;
96100

97101
const auto &children = getChildren();
98102
react_native_assert(
@@ -250,10 +254,8 @@
250254
const auto &decoratorYogaNode = YGNodeGetParent(const_cast<YGNodeRef>(yogaNode));
251255
const auto &decoratorShadowNode = shadowNodeFromContext(decoratorYogaNode);
252256

253-
LayoutContext context{};
254-
context.fontSizeMultiplier = RCTFontSizeMultiplier();
255-
256-
const auto size = decoratorShadowNode.measureContent(context, {minimumSize, maximumSize});
257+
const auto size = decoratorShadowNode.measureContent(
258+
decoratorLayoutContext, {minimumSize, maximumSize});
257259

258260
return YGSize{yogaFloatFromFloat(size.width),
259261
yogaFloatFromFloat(size.height)};

0 commit comments

Comments
 (0)