<View style={{ width: windowWidth, height: windowHeight - 160 }}>
<FlatList
ref={flatListFef}
data={expLoreStore.storeList[route.params.item.npc_id].chat_details}
onContentSizeChange={() => flatListFef.current.scrollToEnd({ animated: false })}
onLayout={() => flatListFef.current.scrollToEnd({ animated: false })}
renderItem={renderItem}
keyExtractor={extractKey}
horizontal={false}
/>
</View>
这个onContentSizeChange()方法,添加item的时候会调用。
场景:IM聊天的时候,聊天信息从底部添加。