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()}
      />
    );
  }
}

相关内容

热门资讯

一秒答解!智星德州可以透视吗,... 一秒答解!智星德州可以透视吗,we poker插件,细节方法(有挂技巧);实战中需综合运用上述技巧,...
玩家必看教程!hhpoker免... 玩家必看教程!hhpoker免费透视脚本,poker辅助器免费安装,wpk教程(有挂透明);玩家必备...
重大通报!pokemmo免费脚... 重大通报!pokemmo免费脚本,德州hhpoker是真的吗,力荐教程(有挂方法)是一款可以让一直输...
实测教程!约局吧如何查看是否有... 实测教程!约局吧如何查看是否有挂,智星菠萝可以辅助吗,wepoke教程(有挂软件)准备好在约局吧如何...
重大通报!epoker底牌透视... 重大通报!epoker底牌透视,wepoker有用吗,存在挂教程(有挂透明),支持语音通讯、好友开房...
必备科技!pokerworld... 必备科技!pokerworld破解版下载,wepoker开脚本视频,曝光教程(有挂方法);支持多人共...
推荐几款新版!德州私人局怎么透... 推荐几款新版!德州私人局怎么透视,pokemmo手机辅助软件,系统教程(有挂透明)是一款可以让一直输...
必备教程!xpoker透视辅助... 必备教程!xpoker透视辅助,HH平台挂,攻略教程(有挂攻略);1分钟了解详细教程(微信 1367...
最新技巧!哈糖大菠萝有挂吗,w... 最新技巧!哈糖大菠萝有挂吗,wepoker私局辅助,可靠技巧(有挂软件);实战中需综合运用上述技巧,...
玩家必看教程!hhpoker怎... 玩家必看教程!hhpoker怎么防作弊,wepoker国外版透视,透明挂教程(有挂方法)是一款可以让...