Force navigation to use root tag

Summary: This diff ensures that JS uses rootTags during navigation. A redbox will be rendered in debug mode when a non-rootTag is used during navigation. This change enables proper navigation for Fabric.

Reviewed By: shergin

Differential Revision: D10855198

fbshipit-source-id: a82aaa706cd62ce92143fa86d0a422c1ae439a50
This commit is contained in:
David Vacca 2018-11-08 16:55:12 -08:00 committed by Facebook Github Bot
parent cd5009f713
commit fe7eb61989
2 changed files with 12 additions and 1 deletions

View File

@ -806,7 +806,9 @@ public class UIManagerModule extends ReactContextBaseJavaModule
* @return the rootTag
*/
public int resolveRootTagFromReactTag(int reactTag) {
return mUIImplementation.resolveRootTagFromReactTag(reactTag);
return ViewUtil.isRootTag(reactTag)
? reactTag
: mUIImplementation.resolveRootTagFromReactTag(reactTag);
}
/** Dirties the node associated with the given react tag */

View File

@ -25,4 +25,13 @@ public class ViewUtil {
return DEFAULT;
}
/**
* @param reactTag {@link int} react tag
* @return if the react tag received by parameter is a RootTag or not.
*/
@Deprecated
public static boolean isRootTag(int reactTag) {
return reactTag % 10 == 1;
}
}