【问题标题】:React Native Scrollview do not have scroll end optionReact Native Scrollview 没有滚动结束选项
【发布时间】:2020-08-30 16:49:28
【问题描述】:

您好,我是 react native 的初学者。 我在使用滚动视图时遇到了一些问题(我想用滚动视图加载更多功能) 我已经用 react native 对设计进行了编码。 现在我读到反应原生滚动视图没有滚动结束事件,但他们推荐 FlatList。 如果我使用 FlatList 我的设计不能顺利工作。 请帮我。 非常感谢。

【问题讨论】:

  • 也许有一些错误,你读到“ScrollView没有scrollToIndex。改用FlatList。”?

标签: react-native


【解决方案1】:
import React, { useRef } from 'react';
import { ScrollView } from 'react-native';

const ScreenComponent = (props) => {
  const scrollViewRef = useRef();
  return (
    <ScrollView
      ref={scrollViewRef}
      onContentSizeChange={() => scrollViewRef.current.scrollToEnd({ animated: true })}
    />
  );
};

使用 scrollViewRef 可以转到滚动视图的末尾..

【讨论】:

    猜你喜欢
    • 2022-12-22
    • 2019-08-13
    • 2022-12-04
    • 2017-06-07
    • 2020-01-08
    • 2018-09-04
    • 2019-07-16
    • 2018-04-09
    • 1970-01-01
    相关资源
    最近更新 更多