bolan9999 / react-native-largelist

The best large list component for React Native.
https://bolan9999.github.io/react-native-largelist/
MIT License
2.32k stars 261 forks source link

Android LargeList scrollTo Error in rn0.59.9 #455

Closed rearlytang closed 2 years ago

rearlytang commented 3 years ago

1 、Mac, Android, Simulator and real device, rn0.59.9, "react-native-spring-scrollview": "version": "3.0.1-rc.5",

2、安卓端使用官方largelist demo,点击某一行后调用scrollTo方法报红屏错误。错误见图片。导致问题的原因是SpringScrollView.js中scrollTo方法调用UIManager.dispatchViewManagerCommand第二个参数“10002”是字符串,rn 0.59.9及之后的版本中(0.59.9之前的版本没有确认)原生类中该方法的第二个参数是int类型,所以出现了红屏错误,手动修改成int数字后就没问题了。出现了该红屏错误后,demo中左边的按钮无法再点击。

rederror debugLargeList rn599

bolan9999 commented 2 years ago

这是react native的版本问题。你说反了,0.60之前是数字,0.60后rn已经弃用数字改为字符串了。详见这个方法

  /**
   * Subclasses may use this method to receive events/commands directly from JS through the {@link
   * UIManager}. Good example of such a command would be {@code scrollTo} request with coordinates
   * for a {@link ScrollView} instance.
   *
   * <p>This method is deprecated use {@link #receiveCommand(View, String, ReadableArray)} instead.
   *
   * @param root View instance that should receive the command
   * @param commandId code of the command
   * @param args optional arguments for the command
   */
  @Deprecated
  public void receiveCommand(@NonNull T root, int commandId, @Nullable ReadableArray args) {}

  /**
   * Subclasses may use this method to receive events/commands directly from JS through the {@link
   * UIManager}. Good example of such a command would be {@code scrollTo} request with coordinates
   * for a {@link ReactScrollView} instance.
   *
   * @param root View instance that should receive the command
   * @param commandId code of the command
   * @param args optional arguments for the command
   */
  public void receiveCommand(@NonNull T root, String commandId, @Nullable ReadableArray args) {}

而且在我的SpringScrollView中也明确写了0.60以下不推荐使用最新版本,只是largelist文档上忘记写了:

React Native版本推荐:

react-native@0.50以下:不确定是否支持,请自行解决原生端问题。

react-native@0.50-0.59:推荐使用react-native-spring-scrollview@2.0.* (最后一位版本号可自行去npm官方查询最新发布的版本)

react-native@0.60+:推荐使用react-native-spring-scrollview@3.0+