Skip to content

Commit b9fc47a

Browse files
Implement multiple view manager lookup for the interop layer on Android
1 parent 1c52d38 commit b9fc47a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManagerRegistry.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,27 @@ public ViewManagerRegistry(Map<String, ViewManager> viewManagerMap) {
5353
* @return the {@link ViewManager} registered to the className received as a parameter
5454
*/
5555
public synchronized ViewManager get(String className) {
56+
// 1. Try to get the manager without the prefix.
5657
ViewManager viewManager = mViewManagers.get(className);
5758
if (viewManager != null) {
5859
return viewManager;
5960
}
61+
62+
// 2. Try to get the manager with the RCT prefix.
63+
String rctViewManagerName = "RCT" + className;
64+
viewManager = mViewManagers.get(rctViewManagerName);
65+
if (viewManager != null) {
66+
return viewManager;
67+
}
6068
if (mViewManagerResolver != null) {
69+
// 1. Try to get the manager without the prefix.
6170
viewManager = getViewManagerFromResolver(className);
6271
if (viewManager != null) return viewManager;
72+
73+
// 2. Try to get the manager with the RCT prefix.
74+
viewManager = getViewManagerFromResolver(rctViewManagerName);
75+
if (viewManager != null) return viewManager;
76+
6377
throw new IllegalViewOperationException(
6478
"ViewManagerResolver returned null for "
6579
+ className

0 commit comments

Comments
 (0)