首页 > 解决方案 > 在反应本机滚动视图中滚动到底部

问题描述

我已经阅读了许多类似的问题并已经实现了这一点。但这似乎不起作用。我希望它每次显示状态更改并添加新元素时滚动到底部。


  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>

我不明白为什么它不起作用

标签: reactjsreact-nativejsx

解决方案


推荐阅读