我最近在 react-native 源代码中注意到以下方法:
public void receiveCommand(@NonNull T root, int commandId, @Nullable ReadableArray args)
Run Code Online (Sandbox Code Playgroud)
ViewManager 类的标记为已弃用。因此,我尝试将其替换为未标记为已弃用的重载版本:
public void receiveCommand(@NonNull T root, String commandId, @Nullable ReadableArray args)
Run Code Online (Sandbox Code Playgroud)
但这个永远不会被调用。我想我可能还需要更改其他一些方法,但是我找不到任何信息,还需要做什么,没有可以遵循的迁移指南。
有谁知道如何正确使用新的、未弃用的 receiveCommand 方法?
ViewManager 的源代码可以在这里找到:https : //github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java