Skip to content

Commit

Permalink
Undo breaking change on ViewManagerDelegate.kt String params (#47086)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cortinico authored and facebook-github-bot committed Oct 17, 2024
1 parent c90ab6e commit 2d2bb9c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class BaseViewManagerDelegate<
@Suppress("NoHungarianNotation") @JvmField protected val mViewManager: U
) : ViewManagerDelegate<T> {
@Suppress("DEPRECATION")
override public fun setProperty(view: T, propName: String, value: Any?) {
override public fun setProperty(view: T, propName: String?, value: Any?) {
when (propName) {
ViewProps.ACCESSIBILITY_ACTIONS ->
mViewManager.setAccessibilityActions(view, value as ReadableArray?)
Expand Down Expand Up @@ -143,6 +143,6 @@ public abstract class BaseViewManagerDelegate<
}
}

override public fun receiveCommand(view: T, commandName: String, args: ReadableArray?): Unit =
override public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?): Unit =
Unit
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,24 @@ import com.facebook.react.bridge.ReadableArray
* @param <T> the type of the view supported by this delegate </T>
*/
public interface ViewManagerDelegate<T : View?> {
public fun setProperty(view: T, propName: String, value: Any?)

public fun receiveCommand(view: T, commandName: String, args: ReadableArray?)
/**
* Sets a property on a view managed by this view manager.
*
* @param view the view to set the property on
* @param propName the name of the property to set (NOTE: should be `String` but is kept as
* `String?` to avoid breaking changes)
* @param value the value to set the property to
*/
public fun setProperty(view: T, propName: String?, value: Any?)

/**
* Executes a command from JS to the view
*
* @param view the view to execute the command on
* @param commandName the name of the command to execute (NOTE: should be `String` but is kept as
* `String?` to avoid breaking changes)
* @param args the arguments to pass to the command
*/
public fun receiveCommand(view: T, commandName: String?, args: ReadableArray?)
}

0 comments on commit 2d2bb9c

Please sign in to comment.