AutoscrollToIndexFlatList在长列表中不起作用
创始人
2024-11-12 15:00:36
0

使用scrollToEnd方法来滚动到列表底部,同时使用setTimeout来延迟滚动,以便在FlatList成功渲染所有项之后再滚动到指定索引处。代码示例:

import { FlatList } from 'react-native';

class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.flatListRef = React.createRef();
  }

  componentDidMount() {
    setTimeout(() => {
      this.flatListRef.current.scrollToEnd({ animated: false });
      this.flatListRef.current.scrollToIndex({
        index: 5,
        animated: true,
        viewPosition: 0.5,
      });
    }, 100);
  }

  renderItem = ({ item }) => {
    return {item};
  };

  render() {
    const { data } = this.props;
    return (
       index.toString()}
      />
    );
  }
}

相关内容

热门资讯

透视计算!wpk透视辅助方法(... 透视计算!wpk透视辅助方法(透视)果然有挂(详细辅助黑科技教程);1、用户打开应用后不用登录就可以...
研究成果!德州来玩辅助器,hh... 这是一款非常优秀的德州来玩辅助器 ia辅助检测软件,能够让你了解到德州来玩辅助器中牌率当中全部隐藏参...
透视挂透视!pokermast... 透视挂透视!pokermaster修改器(透视)真是是有挂(详细辅助技巧教程)1、起透看视 透明视辅...
避坑细节!aapoker辅助软... 1、避坑细节!aapoker辅助软件合法吗,aapoker透视插件,科技教程(有挂透视)。2、aap...
一分钟了解!wepoker破解... 一分钟了解!wepoker破解器有用吗,wepoker辅助器官方,实用技巧(有挂透明)准备好在wep...
透视讲解!wepoker私人局... 透视讲解!wepoker私人局有透视吗(透视)总是是真的有挂(详细辅助详细教程)1、用户打开应用后不...
透视科技!hhpoker万能辅... 透视科技!hhpoker万能辅助器(透视)本来有挂(详细辅助必胜教程)1、hhpoker万能辅助器透...
玩家必用!wepoker数据分... 玩家必用!wepoker数据分析,wepoker辅助器下载,详细教程(有挂技巧)准备好在wepoke...
透视玄学!wepoker怎么下... 透视玄学!wepoker怎么下载游戏(透视)竟然真的是有挂(详细辅助2025新版总结)1、完成的残局...
揭秘关于!wpk辅助器,hhp... 揭秘关于!wpk辅助器,hhpoker哪个俱乐部靠谱,大神讲解(有挂技巧)1、许多玩家不知道hhpo...