recyclerlistview
recyclerlistview copied to clipboard
Scrolling to specific item in the recyclelist view
I am trying to make the scrollTo specific item in the recyclerlistview. However, the event.nativeEvent.layout in the onLayout returns the y value as 0. Other values such as width and height are returned correctly. I think the y is 0 because the item is relative to the parent view/component from the recyclerlistview library. Is there any other way for me to get a correct y value relative to the scrollview of the recyclerlistview ? Thank you so much
Any solution found ?
hi you should use from external scroll View and ref this worked for me after setting ref you can call any function you want on this same as vanilla scroll view
Can you elaborate on use of external scroll view ref? Perhaps a snippet of code? Thanks.
@MarufSharifi can you show any code please? I have the same problem
Edit: I have found a solution
const scrollRef = useRef();
const scrollToTop = () => {
scrollRef?.current._scrollViewRef.scrollTo({ x: 0,
y: 0,
animated: true });
};
...<RecyclerListView
layoutProvider={_layoutProvider}
dataProvider={dataProvider}
rowRenderer={_rowRenderer}
scrollViewProps={{
ref: scrollRef
}}
/>
Can you share snippet for class based as well. I tried createRef instead of useRef, it didn't work. Also I am using forceNonDeterministic true. @Brma1048