When I have to communicate between native and rn, I have to list up command id and name on getCommandsMap
of ViewManager
. And then, I can receive the command from receiveCommand
. I found out that receiveCommand method which has commendId
of Int Type is deprecated, and It seems that only command name(String) makes communication work well.
My question is:
- Is it okay to define any dummy int value on getCommandsMap as counterpart value of command name?
- Why do ViewManager’s getCommandsMap return type is Map<String, Int> ?
/**
* Subclasses of {@link ViewManager} that expect to receive commands through {@link
* UIManagerModule#dispatchViewManagerCommand} should override this method returning the map
* between names of the commands and IDs that are then used in {@link #receiveCommand} method
* whenever the command is dispatched for this particular {@link ViewManager}.
*
* @return map of string to int mapping of the expected commands
*/
public @Nullable Map<String, Integer> getCommandsMap() {
return null;
}
@Deprecated
public void receiveCommand(@NonNull T root, int commandId, @Nullable ReadableArray args) {
}
public void receiveCommand(@NonNull T root, String commandId, @Nullable ReadableArray args) {