Skip to content

Commit 9fdd920

Browse files
adityasharatfacebook-github-bot
authored andcommitted
NavigationBarComponent
Summary: This diff aims to restrict the usage of `Component.measure()` API to resolutions that occur during the layout phase. The API should be used in conjunction with `OnCreateLayoutWithSizeSpec` (for Spec) and `RenderWithConstraints` (for KComponents) when component resolution depends on size constraints. Disallowing `Component.measure()` during the resolve phase is crucial for the following reasons: - Size constraints is unavailable during the resolve phase - Layouts created during resolve need to be cached separately, complicating reconciliation and layout caching - Layout typically occurs after resolve, not vice versa. Hence performing layout during the resolve phase disrupts the natural sequence, leading to unnecessary complexity and potential issues. By restricting `Component.measure()` to the layout phase, we ensure components remain reusable, maintain a stable progression of phases, and avoid potential performance regressions and hard-to-debug issues. Reviewed By: zielinskimz Differential Revision: D75129940 fbshipit-source-id: ccb5d8ca227f9c1fc9cd7f0a4ae662553836a61e
1 parent a8e7905 commit 9fdd920

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

litho-widget-kotlin/src/main/kotlin/com/facebook/litho/kotlin/widget/RenderWithConstraints.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ fun ResourcesScope.RenderWithConstraints(
6767
return RenderWithConstraints.create(context).content(content).kotlinStyle(style).build()
6868
}
6969

70+
fun RenderWithConstraints(
71+
context: ComponentContext,
72+
style: Style? = null,
73+
content: ComponentScope.(SizeConstraints) -> Component
74+
): Component {
75+
return RenderWithConstraints.create(context).content(content).kotlinStyle(style).build()
76+
}
77+
7078
@ExcuseMySpec(reason = Reason.J2K_CONVERSION)
7179
@LayoutSpec
7280
private object RenderWithConstraintsSpec {

0 commit comments

Comments
 (0)