Skip to content

Commit 7a31dad

Browse files
NickGerlemanfacebook-github-bot
authored andcommitted
Breaking: Remove BaseViewManagerInterface (#46809)
Summary: BaseViewManagerInterface isn't adding much value right now. It was added in D16984121 to allow codegen generated ViewManager delegates to apply to view managers which derive from ViewMangager instead of BaseViewManager (if they did some cleverness, to make VM delegate apply to a no-op class, still implementing all of BaseViewManager's methods). All of the cases where that was used have since been moved to `SimpleViewManager`, and `BaseViewManagerAdapter` (needed to wire this together) doesn't exist anymore, so it's not possible to take any advantage of this interface existing. We should remove it, since its existence is a source of error (e.g. it was missing setters for `accessibilityValue` or those related to pointer events), and is more generally confusing for anyone adding to `BaseViewManager` in the future. This is a breaking change, because there are some libraries which vendor a copy of generated ViewManagerDelegate when building against legacy arch to be able to share code normally generated at build time. That means these will need to be updated to maintain compatibility with RN versions of 0.77+ with new arch disabled. This will not effect compatibility of these libraries against the default new arch, and the updated delegate is still compatible with older RN version. ``` sourceSets.main { java { if (!isNewArchitectureEnabled()) { srcDirs += [ "src/paper/java", ] } } } ``` 1. `rnmapbox/maps` 2. `react-native-gesture-handler` 3. `react-native-screens` 4. `react-native-svg` 5. `react-native-safe-area-context` 6. `react-native-pdf` Changelog: [Android][Breaking] - Remove BaseViewManagerInterface Differential Revision: D63819044
1 parent b7bcdcd commit 7a31dad

File tree

9 files changed

+172
-271
lines changed

9 files changed

+172
-271
lines changed

packages/react-native-codegen/e2e/__tests__/components/__snapshots__/GeneratePropsJavaDelegate-test.js.snap

Lines changed: 54 additions & 36 deletions
Large diffs are not rendered by default.

packages/react-native-codegen/src/generators/components/GeneratePropsJavaDelegate.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ package ${packageName};
5555
5656
${imports}
5757
58-
public class ${className}<T extends ${extendClasses}, U extends BaseViewManagerInterface<T> & ${interfaceClassName}<T>> extends BaseViewManagerDelegate<T, U> {
58+
public class ${className}<T extends ${extendClasses}, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ${interfaceClassName}<T>> extends BaseViewManagerDelegate<T, U> {
5959
public ${className}(U viewManager) {
6060
super(viewManager);
6161
}
@@ -272,7 +272,8 @@ function getDelegateImports(component: ComponentShape) {
272272
}
273273
imports.add('import androidx.annotation.Nullable;');
274274
imports.add('import com.facebook.react.uimanager.BaseViewManagerDelegate;');
275-
imports.add('import com.facebook.react.uimanager.BaseViewManagerInterface;');
275+
imports.add('import com.facebook.react.uimanager.BaseViewManager;');
276+
imports.add('import com.facebook.react.uimanager.LayoutShadowNode;');
276277

277278
return imports;
278279
}

packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap

Lines changed: 90 additions & 60 deletions
Large diffs are not rendered by default.

packages/react-native-popup-menu-android/android/src/main/java/com/facebook/react/viewmanagers/AndroidPopupMenuManagerDelegate.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
import androidx.annotation.Nullable;
1414
import com.facebook.react.bridge.ReadableArray;
1515
import com.facebook.react.uimanager.BaseViewManagerDelegate;
16-
import com.facebook.react.uimanager.BaseViewManagerInterface;
16+
import com.facebook.react.uimanager.BaseViewManager;
17+
import com.facebook.react.uimanager.LayoutShadowNode;
1718

18-
public class AndroidPopupMenuManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & AndroidPopupMenuManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
19+
public class AndroidPopupMenuManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & AndroidPopupMenuManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
1920
public AndroidPopupMenuManagerDelegate(U viewManager) {
2021
super(viewManager);
2122
}

packages/react-native-test-library/android/src/main/java/com/facebook/react/viewmanagers/SampleNativeComponentManagerDelegate.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
import androidx.annotation.Nullable;
1414
import com.facebook.react.bridge.ReadableArray;
1515
import com.facebook.react.uimanager.BaseViewManagerDelegate;
16-
import com.facebook.react.uimanager.BaseViewManagerInterface;
16+
import com.facebook.react.uimanager.BaseViewManager;
17+
import com.facebook.react.uimanager.LayoutShadowNode;
1718

18-
public class SampleNativeComponentManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & SampleNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
19+
public class SampleNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & SampleNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
1920
public SampleNativeComponentManagerDelegate(U viewManager) {
2021
super(viewManager);
2122
}

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,7 +4108,7 @@ public final class com/facebook/react/uimanager/BackgroundStyleApplicator {
41084108
public static final fun setOutlineWidth (Landroid/view/View;F)V
41094109
}
41104110

4111-
public abstract class com/facebook/react/uimanager/BaseViewManager : com/facebook/react/uimanager/ViewManager, android/view/View$OnLayoutChangeListener, com/facebook/react/uimanager/BaseViewManagerInterface {
4111+
public abstract class com/facebook/react/uimanager/BaseViewManager : com/facebook/react/uimanager/ViewManager, android/view/View$OnLayoutChangeListener {
41124112
public fun <init> ()V
41134113
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
41144114
public fun getExportedCustomBubblingEventTypeConstants ()Ljava/util/Map;
@@ -4187,48 +4187,12 @@ public abstract class com/facebook/react/uimanager/BaseViewManager : com/faceboo
41874187
}
41884188

41894189
public abstract class com/facebook/react/uimanager/BaseViewManagerDelegate : com/facebook/react/uimanager/ViewManagerDelegate {
4190-
protected final field mViewManager Lcom/facebook/react/uimanager/BaseViewManagerInterface;
4191-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
4190+
protected final field mViewManager Lcom/facebook/react/uimanager/BaseViewManager;
4191+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
41924192
public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
41934193
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
41944194
}
41954195

4196-
public abstract interface class com/facebook/react/uimanager/BaseViewManagerInterface {
4197-
public abstract fun setAccessibilityActions (Landroid/view/View;Lcom/facebook/react/bridge/ReadableArray;)V
4198-
public abstract fun setAccessibilityCollection (Landroid/view/View;Lcom/facebook/react/bridge/ReadableMap;)V
4199-
public abstract fun setAccessibilityCollectionItem (Landroid/view/View;Lcom/facebook/react/bridge/ReadableMap;)V
4200-
public abstract fun setAccessibilityHint (Landroid/view/View;Ljava/lang/String;)V
4201-
public abstract fun setAccessibilityLabel (Landroid/view/View;Ljava/lang/String;)V
4202-
public abstract fun setAccessibilityLabelledBy (Landroid/view/View;Lcom/facebook/react/bridge/Dynamic;)V
4203-
public abstract fun setAccessibilityLiveRegion (Landroid/view/View;Ljava/lang/String;)V
4204-
public abstract fun setAccessibilityRole (Landroid/view/View;Ljava/lang/String;)V
4205-
public abstract fun setBackgroundColor (Landroid/view/View;I)V
4206-
public abstract fun setBorderBottomLeftRadius (Landroid/view/View;F)V
4207-
public abstract fun setBorderBottomRightRadius (Landroid/view/View;F)V
4208-
public abstract fun setBorderRadius (Landroid/view/View;F)V
4209-
public abstract fun setBorderTopLeftRadius (Landroid/view/View;F)V
4210-
public abstract fun setBorderTopRightRadius (Landroid/view/View;F)V
4211-
public abstract fun setElevation (Landroid/view/View;F)V
4212-
public abstract fun setFilter (Landroid/view/View;Lcom/facebook/react/bridge/ReadableArray;)V
4213-
public abstract fun setImportantForAccessibility (Landroid/view/View;Ljava/lang/String;)V
4214-
public abstract fun setMixBlendMode (Landroid/view/View;Ljava/lang/String;)V
4215-
public abstract fun setNativeId (Landroid/view/View;Ljava/lang/String;)V
4216-
public abstract fun setOpacity (Landroid/view/View;F)V
4217-
public abstract fun setRenderToHardwareTexture (Landroid/view/View;Z)V
4218-
public abstract fun setRole (Landroid/view/View;Ljava/lang/String;)V
4219-
public abstract fun setRotation (Landroid/view/View;F)V
4220-
public abstract fun setScaleX (Landroid/view/View;F)V
4221-
public abstract fun setScaleY (Landroid/view/View;F)V
4222-
public abstract fun setShadowColor (Landroid/view/View;I)V
4223-
public abstract fun setTestId (Landroid/view/View;Ljava/lang/String;)V
4224-
public abstract fun setTransform (Landroid/view/View;Lcom/facebook/react/bridge/ReadableArray;)V
4225-
public abstract fun setTransformOrigin (Landroid/view/View;Lcom/facebook/react/bridge/ReadableArray;)V
4226-
public abstract fun setTranslateX (Landroid/view/View;F)V
4227-
public abstract fun setTranslateY (Landroid/view/View;F)V
4228-
public abstract fun setViewState (Landroid/view/View;Lcom/facebook/react/bridge/ReadableMap;)V
4229-
public abstract fun setZIndex (Landroid/view/View;F)V
4230-
}
4231-
42324196
public abstract interface class com/facebook/react/uimanager/ComponentNameResolver {
42334197
public abstract fun getComponentNames ()[Ljava/lang/String;
42344198
}
@@ -6297,7 +6261,7 @@ public final class com/facebook/react/util/RNLog {
62976261
}
62986262

62996263
public class com/facebook/react/viewmanagers/ActivityIndicatorViewManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6300-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6264+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
63016265
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
63026266
}
63036267

@@ -6309,7 +6273,7 @@ public abstract interface class com/facebook/react/viewmanagers/ActivityIndicato
63096273
}
63106274

63116275
public class com/facebook/react/viewmanagers/AndroidDrawerLayoutManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6312-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6276+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
63136277
public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
63146278
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
63156279
}
@@ -6326,7 +6290,7 @@ public abstract interface class com/facebook/react/viewmanagers/AndroidDrawerLay
63266290
}
63276291

63286292
public class com/facebook/react/viewmanagers/AndroidHorizontalScrollContentViewManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6329-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6293+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
63306294
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
63316295
}
63326296

@@ -6335,7 +6299,7 @@ public abstract interface class com/facebook/react/viewmanagers/AndroidHorizonta
63356299
}
63366300

63376301
public class com/facebook/react/viewmanagers/AndroidProgressBarManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6338-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6302+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
63396303
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
63406304
}
63416305

@@ -6350,7 +6314,7 @@ public abstract interface class com/facebook/react/viewmanagers/AndroidProgressB
63506314
}
63516315

63526316
public class com/facebook/react/viewmanagers/AndroidSwipeRefreshLayoutManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6353-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6317+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
63546318
public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
63556319
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
63566320
}
@@ -6366,7 +6330,7 @@ public abstract interface class com/facebook/react/viewmanagers/AndroidSwipeRefr
63666330
}
63676331

63686332
public class com/facebook/react/viewmanagers/AndroidSwitchManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6369-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6333+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
63706334
public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
63716335
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
63726336
}
@@ -6385,7 +6349,7 @@ public abstract interface class com/facebook/react/viewmanagers/AndroidSwitchMan
63856349
}
63866350

63876351
public class com/facebook/react/viewmanagers/DebuggingOverlayManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6388-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6352+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
63896353
public fun receiveCommand (Landroid/view/View;Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;)V
63906354
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
63916355
}
@@ -6397,7 +6361,7 @@ public abstract interface class com/facebook/react/viewmanagers/DebuggingOverlay
63976361
}
63986362

63996363
public class com/facebook/react/viewmanagers/ModalHostViewManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6400-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6364+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
64016365
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
64026366
}
64036367

@@ -6414,15 +6378,15 @@ public abstract interface class com/facebook/react/viewmanagers/ModalHostViewMan
64146378
}
64156379

64166380
public class com/facebook/react/viewmanagers/SafeAreaViewManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6417-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6381+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
64186382
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
64196383
}
64206384

64216385
public abstract interface class com/facebook/react/viewmanagers/SafeAreaViewManagerInterface {
64226386
}
64236387

64246388
public class com/facebook/react/viewmanagers/UnimplementedNativeViewManagerDelegate : com/facebook/react/uimanager/BaseViewManagerDelegate {
6425-
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManagerInterface;)V
6389+
public fun <init> (Lcom/facebook/react/uimanager/BaseViewManager;)V
64266390
public fun setProperty (Landroid/view/View;Ljava/lang/String;Ljava/lang/Object;)V
64276391
}
64286392

0 commit comments

Comments
 (0)