javascript - react native SectionList 滚动到部分

标签 javascript reactjs react-native

我刚刚将我的 ListView 更改为 React Native 的新 SectionList,现在当我尝试使用 scrollTo 函数时应用程序崩溃,并指出它未定义。我尝试查找可能有帮助的新功能/替代功能,但它们似乎都不起作用。

使用新的 SectionList 以编程方式滚动到特定部分的正确协议(protocol)是什么?

到目前为止我一直在咨询的链接: https://github.com/facebook/react-native/issues/13151 https://facebook.github.io/react-native/releases/0.43/docs/virtualizedlist.html#scrolltoend

我目前的尝试:

var params = {animated:true,offset:Platform.OS == "ios" ? 244 : 264}
_mainListView.scrollToOffset(params)

最佳答案

<SectionList
          ref={(sectionList) => { this.sectionList = sectionList }} .../>

this.sectionList.scrollToLocation(
        {
          sectionIndex: sectionIndex,
          itemIndex: itemIndex
        }
      );

这就是我过去使用这篇文章和 https://snack.expo.io/HJp9mEQkG 的组合来让它工作的方法

关于javascript - react native SectionList 滚动到部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43452859/

相关文章:

javascript - 动态激活自定义类按钮

reactjs - 如何使用 Redux-form 从复选框获取值?

react-native - React Native 只允许 TextInput 的小写输入

javascript - setTimeout(task, 0) 是否导致 IE 出现问题?

javascript - 如何使用节点和 .createElement ("b") 使文本加粗?

javascript - 函数仅检查数组中的最后一项

javascript - Promises 不等待解析或拒绝 - javascript - ReactJs

javascript - React Native WebView JavaScript 构建问题

java - Android Gradle 插件需要 Java 11 才能运行。您当前使用的是 Java 1.8

javascript - MongoDB 尝试部署 Meteor 应用程序时出现问题