question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Will this move to FlatList instead of ListView ??

FlatList has a handy feature scrollToItem that I would like to use with this library.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:18
  • Comments:8

github_iconTop GitHub Comments

7reactions
vTripcommented, Aug 29, 2017

Will be uploading my FlatList version of this library to a repo soon. It is a WIP. Would love some assistance with finishing it off. For anyone interested I will post a link here when it is up.

0reactions
gazickilcommented, Mar 19, 2018

@vTrip the scrollToItem can be easly done using current code.

you can use internal layoutMap which contains array of all rows layouts (xPos, yPox, height, width)

Example function:

scrollToIndex = (index, animated) => {
    const y = this._list.layoutMap[index.toString()].y
    this._list.scrollTo({ x: 0, y: y , animated: true });
};

I use it to scroll when adding new element or on load. I’m using setTimeout as i’m waiting for redux to update the store and for list to catch up with the data update.

  componentDidMount() {
    setTimeout(() => {
      this.scrollToIndex(this.props.selectedConfigIdx, false);
    }, 300);
  }

  componentDidUpdate(prevProps, prevState) {
    if (prevProps.selectedConfigIdx !== this.props.selectedConfigIdx && this._areWeDuringAddNewConfig) {
      setTimeout(() => {
        this.scrollToIndex(this.props.selectedConfigIdx, true);
      }, 100);
    }
  }

  _addNewConfig = () => {
    if (this._areWeDuringAddNewConfig) {
      return;
    }

    this._areWeDuringAddNewConfig = true;
    this.props.onConfigAdd();
  };

  scrollToIndex = (index, animated) => {
    const y = this._list.layoutMap[index.toString()].y;
    this._areWeDuringAddNewConfig = false;
    this._list.scrollTo({ x: 0, y: y, animated: animated });
  };
Read more comments on GitHub >

github_iconTop Results From Across the Web

FlatList - React Native
A performant interface for rendering basic, flat lists, supporting the most handy features: Fully cross-platform. Optional horizontal mode.
Read more >
A deep dive into React Native FlatList - LogRocket Blog
FlatList is a React Native component that allows you to render lists with zero hassle ... FlatList also has support for header components....
Read more >
Features of React Native FlatList - eduCBA
Features of React Native Flatlist · Pull to refresh support · Header support · Footer support · Separator support · Scroll loading support...
Read more >
Displaying a List in React Native: Map Method or FlatList ...
Scroll to a specific position in the list; Multiple column support. Under the hood, FlatList uses the ScrollView component to render scrollable elements....
Read more >
FlatList · React Native
Scroll loading. ScrollToIndex support. If you need section support, use <SectionList> . Minimal Example: <FlatList data={ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found