我正在尝试使用react-native flatlist 的scrollToIndex 函数。我期望的是字母列表视图。太使用scrollToIndex,我需要设置 flatlist 组件的 getItemLayout 属性。我已经渲染了与父平面列表中的项目具有相同字母的项目,并渲染了子平面列表中的项目,因此父平面列表的项目高度有所不同。问题是,如果我给出 getItemLayout 属性,它会给我如下错误。
不变违规: 不变违规: 不变违规: 不变违规: 当提供测量度量函数时,不必估计帧
<FlatList data={this.cityList}
renderItem={this.renderCityGroup}
style={styles.cityList}
keyExtractor={(item, index) => item + index}
getItemLayout={(data, index) => {
return {
length: data.height,
offset: data.total
}
}}
ref={ref => this.cityListRef = ref}
/>
Run Code Online (Sandbox Code Playgroud)
这是我当前的代码。