Flipkart / recyclerlistview

High performance listview for React Native and web!
Apache License 2.0
5.17k stars 420 forks source link

Internal length of list? #764

Closed OmarJay1 closed 1 year ago

OmarJay1 commented 1 year ago

Hello, is there a way of retrieving the internal length of the list view?

What's happening is that I call a Navigator stack form for items which has a delete function. If the very last item in the list is deleted I get an exception, when going back on to the list.

For instance if I have 5 items remaining in the data, I get this:

LayoutUnavailableException: No layout available for index: 5, js engine: hermes

I'm guessing that the internal list is out of sync with the data. If I do something like this, it might work better:

render() {
if (listRef.internalLength > this.props.data.length) {

 return(<><Text>Loading...</Text><>);

}

return() {
// usual return
}

I really don't know, but I'm at a loss as to what's going on.

Thanks.

OmarJay1 commented 1 year ago

Oops, my problem was that I was setting initialRenderIndex in order to start at the proper item after updating or deleting. If I deleted the last item, then the index would be larger than the list size and throw and error.

Thanks.