Skip to content

Commit

Permalink
Skips mount for initial empty component layout
Browse files Browse the repository at this point in the history
Summary: Skips mount for initial empty component layout

Reviewed By: astreet

Differential Revision: D55377095

fbshipit-source-id: 03679e027ccdd0d9852bd91298eeb1b2861fc7f7
  • Loading branch information
adityasharat authored and facebook-github-bot committed Mar 28, 2024
1 parent 972ba38 commit d7c66c8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -853,10 +853,19 @@ private void promoteCommittedLayoutStateToUI() {
if (mCommittedLayoutState == null) {
throw new RuntimeException("Cannot promote null LayoutState!");
}

if (mCommittedLayoutState == mMainThreadLayoutState) {
return;
}

final @Nullable LayoutState previousMainThreadLayoutState = mMainThreadLayoutState;
mMainThreadLayoutState = mCommittedLayoutState;

if (LayoutState.isNullOrEmpty(previousMainThreadLayoutState)
&& LayoutState.isNullOrEmpty(mCommittedLayoutState)) {
return;
}

dispatchOnAttached();

if (mLithoView != null) {
Expand Down
8 changes: 8 additions & 0 deletions litho-core/src/main/java/com/facebook/litho/LayoutState.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ boolean hasComponentsExcludedFromIncrementalMount() {
return mHasComponentsExcludedFromIncrementalMount;
}

public boolean isEmpty() {
return mResolveResult.component instanceof EmptyComponent;
}

public RenderTree toRenderTree() {
if (mCachedRenderTree != null) {
return mCachedRenderTree;
Expand Down Expand Up @@ -737,4 +741,8 @@ public VisibilityBoundsTransformer getVisibilityBoundsTransformer() {
public Map<Long, DynamicValueOutput> getDynamicValueOutputs() {
return mDynamicValueOutputs;
}

public static boolean isNullOrEmpty(@Nullable LayoutState layoutState) {
return layoutState == null || layoutState.isEmpty();
}
}

0 comments on commit d7c66c8

Please sign in to comment.