diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index a01798d0bf..9058dcc7b1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -498,7 +498,6 @@ public class SurfaceMountingManager { view = viewManager.createView( reactTag, mThemedReactContext, propsDiffMap, stateWrapper, mJSResponderHandler); - view.setId(reactTag); } ViewState viewState = new ViewState(reactTag, view, viewManager); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java index ac2a51d668..e429eba16a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeViewHierarchyManager.java @@ -282,14 +282,6 @@ public class NativeViewHierarchyManager { viewManager.createView(tag, themedContext, initialProps, null, mJSResponderHandler); mTagsToViews.put(tag, view); mTagsToViewManagers.put(tag, viewManager); - - // Use android View id field to store React tag. This is possible since we don't inflate - // React views from layout xmls. Thus it is easier to just reuse that field instead of - // creating another (potentially much more expensive) mapping from view to React tag - view.setId(tag); - if (initialProps != null) { - viewManager.updateProperties(view, initialProps); - } } finally { Systrace.endSection(Systrace.TRACE_TAG_REACT_VIEW); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java index cf1be7c7ce..ccde14ae9c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java @@ -122,7 +122,10 @@ public abstract class ViewManager /** * Subclasses should return a new View instance of the proper type. This is an optional method * that will call createViewInstance for you. Override it if you need props upon creation of the - * view. + * view, or state. + * + *

If you override this method, you *must* guarantee that you you're handling updateProperties, + * view.setId, addEventEmitters, and updateState/updateExtraData properly! * * @param reactTag reactTag that should be set as ID of the view instance * @param reactContext ReactContext used to initialize view instance @@ -140,6 +143,7 @@ public abstract class ViewManager if (initialProps != null) { updateProperties(view, initialProps); } + // Only present in Fabric; but always present in Fabric. if (stateWrapper != null) { Object extraData = updateState(view, initialProps, stateWrapper); if (extraData != null) {