mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RN Android: Support View Manager Commands that are strings
Summary:
Right now JS triggers a view manager command with the following code:
```
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
UIManager.getViewManagerConfig('RCTView').Commands.hotspotUpdate,
[destX || 0, destY || 0],
);
```
As we want to get rid of calls to UIManager, we need to stop looking for the integer defined in native from JavaScript. We will be changing methods like this to be:
```
UIManager.dispatchViewManagerCommand(
ReactNative.findNodeHandle(this),
'hotspotUpdate',
[destX || 0, destY || 0],
);
```
We need to support ints and Strings to be backwards compatible, but ints will be deprecated.
Reviewed By: shergin
Differential Revision: D15955444
fbshipit-source-id: d1c488975ae03404f8f851a7035b58a90ed34163
This commit is contained in:
committed by
Facebook Github Bot
parent
4b8d07ebf3
commit
3cae6fa950
+15
@@ -770,6 +770,21 @@ public class NativeViewHierarchyManager {
|
||||
viewManager.receiveCommand(view, commandId, args);
|
||||
}
|
||||
|
||||
public synchronized void dispatchCommand(
|
||||
int reactTag,
|
||||
String commandId,
|
||||
@Nullable ReadableArray args) {
|
||||
UiThreadUtil.assertOnUiThread();
|
||||
View view = mTagsToViews.get(reactTag);
|
||||
if (view == null) {
|
||||
throw new IllegalViewOperationException("Trying to send command to a non-existing view " +
|
||||
"with tag " + reactTag);
|
||||
}
|
||||
|
||||
ViewManager viewManager = resolveViewManager(reactTag);
|
||||
viewManager.receiveCommand(view, commandId, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a {@link PopupMenu}.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user