首页 > 解决方案 > scrollToIndex 在 RTL FlatList React-Native 中不起作用

问题描述

我有 Horizo​​ntal FlatList,现在我将电话语言更改为阿拉伯语 (RTL)。scrollToIndex() 在 RTL 中不起作用,没有 RTL,它可以按预期正常工作。有什么建议么?

平面列表

<FlatList
    style={myStyles.flatListStyle}
    horizontal={true}
    data={this.props.dataForFlatList}
    renderItem={this.renderItem}
    ref={(ref) => { this.flatListRef = ref; }}
    keyExtractor={item => item.id.toString()} />

Press() 上的 renderItem 函数正在传递项目 ID

this.flatListRef.scrollToIndex({ animated: true, index: id }); // Working fine without RTL - NOT WORKING WITH RTL

提前致谢。

标签: react-nativereact-native-androidreact-native-flatlistscrolltoindex

解决方案


如果您在渲染窗口之外滚动,则需要指定getItemLayout道具


推荐阅读