Align View creation flow between Fabric and non-Fabric
Summary: Ship responsibility for most View creation logic to ViewManager, where it already largely lies, and simplify code in Fabric and non-Fabric mounting layers. Notably, some of this work was *already* being duplicated so we can expect an extremely tiny perf gain here. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26742711 fbshipit-source-id: 4213766d4cd366bc69cd47d4654f7b269bb9e7f4
This commit is contained in:
Родитель
ea3495399b
Коммит
a65cd683ae
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -122,7 +122,10 @@ public abstract class ViewManager<T extends View, C extends ReactShadowNode>
|
|||
/**
|
||||
* 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.
|
||||
*
|
||||
* <p>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<T extends View, C extends ReactShadowNode>
|
|||
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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче