reactjs - 在反应本机滚动视图中滚动到底部
问题描述
我已经阅读了许多类似的问题并已经实现了这一点。但这似乎不起作用。我希望它每次显示状态更改并添加新元素时滚动到底部。
return (
<View style={styles.container}>
<ScrollView style={styles.main} ref={scrollViewRef}
onContentSizeChange={() => scrollViewRef.current.scrollToEnd({ animated: true })}>
{ShowingStates.map((State, index) => {
if (Object.keys(State) == "info") {
return <Info info={State.info} qId={index} />
}
if (Object.keys(State) == "question") {
return <Question question={State.question} onPress={onPress} qId={index} />
}
}
)}
</ScrollView>
</View>
我不明白为什么它不起作用
解决方案
推荐阅读
- mysql - MySQL 无法使用 SELECT IN 检索重复的行
- reactjs - 在 svg 中嵌入 svg 的样式(在 Chrome 上)
- php - Laravel 7:尝试获取名称而不是 id
- angular - Angular 10.1 Ivy 不理解 *ngFor 指令
- next.js - create-next-app 不起作用,出现内部服务器错误
- postgresql - 通过 VPC 连接器连接 Google Cloud Platform 的计算引擎和应用引擎
- python - 使用 pybind11 将向量从 C++ 传递到 Python
- java - 无法识别 startActivityForResult 中的 int?
- arrays - 两个指针问题和滑动窗口一样吗
- python - Python Pandas set_index 函数:KeyError:“列中都没有 []”