Skip to content

Commit b316260

Browse files
mdvaccafacebook-github-bot
authored andcommitted
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
1 parent 48f1686 commit b316260

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,9 @@ public void removeUIManagerListener(UIManagerModuleListener listener) {
806806
* @return the rootTag
807807
*/
808808
public int resolveRootTagFromReactTag(int reactTag) {
809-
return mUIImplementation.resolveRootTagFromReactTag(reactTag);
809+
return ViewUtil.isRootTag(reactTag)
810+
? reactTag
811+
: mUIImplementation.resolveRootTagFromReactTag(reactTag);
810812
}
811813

812814
/** Dirties the node associated with the given react tag */

ReactAndroid/src/main/java/com/facebook/react/uimanager/common/ViewUtil.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@ public static int getUIManagerType(int reactTag) {
2525
return DEFAULT;
2626
}
2727

28+
/**
29+
* @param reactTag {@link int} react tag
30+
* @return if the react tag received by parameter is a RootTag or not.
31+
*/
32+
@Deprecated
33+
public static boolean isRootTag(int reactTag) {
34+
return reactTag % 10 == 1;
35+
}
36+
2837
}

0 commit comments

Comments
 (0)