Skip to content

Commit ce16206

Browse files
cortinicocipolleschi
authored andcommitted
Undo breaking change on ViewManagerDelegate.kt String params (#47086)
Summary: Pull Request resolved: #47086 When we migrated `ViewManagerDelegate` to Kotlin, we convered his string params to be `String` (rather than `String?`). Existing implementation of this interface in OSS written in Kotlin were using `String?` due to this interface being in Java (and not being Nullsafe annotated). Therefore now changing this interface from `String?` to `String` is a breaking change for them. Affected libraries are: https://github.com/search?q=%22fun+receiveCommand%28%22+%22commandId%3A+String%3F%22+%22args%3A+ReadableArray%22+language%3Akotlin+-org%3Afacebook+-is%3Afork&type=code&p=4 This prevents the breaking change and should be included in 0.76. Changelog: [Android] [Fixed] - Undo breaking change on ViewManagerDelegate.kt String params Reviewed By: cipolleschi Differential Revision: D64532446 fbshipit-source-id: aac286554ad0e35f557160f900bcbad1acc5930d
1 parent ab0d812 commit ce16206

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import com.facebook.yoga.YogaConstants
2222
public abstract class BaseViewManagerDelegate<T : View, U : BaseViewManagerInterface<T>>(
2323
@Suppress("NoHungarianNotation") @JvmField protected val mViewManager: U
2424
) : ViewManagerDelegate<T> {
25-
override public fun setProperty(view: T, propName: String, value: Any?) {
25+
override public fun setProperty(view: T, propName: String?, value: Any?) {
2626
when (propName) {
2727
ViewProps.ACCESSIBILITY_ACTIONS ->
2828
mViewManager.setAccessibilityActions(view, value as ReadableArray?)
@@ -104,6 +104,6 @@ public abstract class BaseViewManagerDelegate<T : View, U : BaseViewManagerInter
104104
}
105105
}
106106

107-
override public fun receiveCommand(view: T, commandName: String, args: ReadableArray?): Unit =
107+
override public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?): Unit =
108108
Unit
109109
}

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,24 @@ import com.facebook.react.bridge.ReadableArray
1818
* @param <T> the type of the view supported by this delegate </T>
1919
*/
2020
public interface ViewManagerDelegate<T : View?> {
21-
public fun setProperty(view: T, propName: String, value: Any?)
2221

23-
public fun receiveCommand(view: T, commandName: String, args: ReadableArray?)
22+
/**
23+
* Sets a property on a view managed by this view manager.
24+
*
25+
* @param view the view to set the property on
26+
* @param propName the name of the property to set (NOTE: should be `String` but is kept as
27+
* `String?` to avoid breaking changes)
28+
* @param value the value to set the property to
29+
*/
30+
public fun setProperty(view: T, propName: String?, value: Any?)
31+
32+
/**
33+
* Executes a command from JS to the view
34+
*
35+
* @param view the view to execute the command on
36+
* @param commandName the name of the command to execute (NOTE: should be `String` but is kept as
37+
* `String?` to avoid breaking changes)
38+
* @param args the arguments to pass to the command
39+
*/
40+
public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?)
2441
}

0 commit comments

Comments
 (0)