Check if view exists before skipping CREATE command

Summary:
Updates early return in the CREATE command codepath that checks if the view already exists before allocating it. Normally the view state is expected to be created only if the view is preallocated, but empty view state is also created for the flattened nodes when they create an event emitter.

By checking the view existence, we can ensure that view was indeed preallocated before, and skip for optimization purposes.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D34050884

fbshipit-source-id: 489fc1052fec9f71712ea729121ac8ef3e3f3d4e
This commit is contained in:
Andrei Shikov
2022-02-08 08:29:02 -08:00
committed by Facebook GitHub Bot
parent 669cd0257c
commit ebc856b2de
@@ -548,7 +548,8 @@ public class SurfaceMountingManager {
// generated.
// This represents a perf issue only, not a correctness issue. In the future we need to
// refactor View preallocation to correct the currently incorrect assumptions.
if (getNullableViewState(reactTag) != null) {
ViewState viewState = getNullableViewState(reactTag);
if (viewState != null && viewState.mView != null) {
return;
}