版本"react-native": "0.74.2",
<FlatList
style={{width: '100%'}}
ref={flatListRef}
data={list}
renderItem={chatItem}
keyExtractor={item => item.id}
// onScroll={handleScroll}
onContentSizeChange={() => {
// 内容大小变化时,如果未手动滚动,则滚动到底部
// if (!scrollEnabled) {
scrollToBottom();
// }
}}></FlatList>
const scrollToBottom = () => {
// console.log('滚到底部');
// flatListRef.current?.scrollToEnd({animated: true});
(flatListRef.current as any)._listRef._scrollRef.scrollToEnd({
animated: true,
});
};
使用这个能滚动到底部
(flatListRef.current as any)._listRef._scrollRef.scrollToEnd()