Guard against setId being called on the ReactRootView outside of RN core
Summary: The RootView being managed by Fabric should have an id of View.NO_ID when it is "handed over" to RN. This is true for Fabric and non-Fabric and setting a custom id on the ReactRootView has never been supported. I'm temporarily (?) adding an additional check earlier and into ReactRootView to hopefully catch any of these issues early. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26077509 fbshipit-source-id: 59e1ec080504e50698acc654c29120f039238a96
This commit is contained in:
Родитель
335d9d88e1
Коммит
4f3b174120
|
@ -646,6 +646,16 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
|||
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "attachToReactInstanceManager");
|
||||
ReactMarker.logMarker(ReactMarkerConstants.ROOT_VIEW_ATTACH_TO_REACT_INSTANCE_MANAGER_START);
|
||||
|
||||
// React Native requires that the RootView id be managed entirely by React Native, and will
|
||||
// crash in addRootView/startSurface if the native View id isn't set to NO_ID.
|
||||
if (getId() != View.NO_ID) {
|
||||
throw new IllegalViewOperationException(
|
||||
"Trying to attach a ReactRootView with an explicit id already set to ["
|
||||
+ getId()
|
||||
+ "]. React Native uses the id field to track react tags and will overwrite this"
|
||||
+ " field. If that is fine, explicitly overwrite the id field to View.NO_ID.");
|
||||
}
|
||||
|
||||
try {
|
||||
if (mIsAttachedToInstance) {
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче