You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement a bookmark feature, that will scroll to a certain index when opening the list.
I am faced with 2 issues and would like some help.
One is the best way of doing scrollTo. Should I use the ref function or the prop. With the ref function, I had to do the below to make it work but I'm not sure if there is a better way.
useEffect(() => {
if (!verseNumber) return;
let index = 0;
const interval = setInterval(() => {
if (listRef.current && index < Number(verseNumber) - 1) {
listRef.current.scrollToIndex({
index: index,
animated: true,
});
index++;
} else {
clearInterval(interval);
}
}, 50);
}, []);
The second and main issue is that the scrolling to the bookmarked verse is inconsistent.
Somethimes it will land quite a few indexes away from the target.
I was told to use the overrideItemLayout but I'm not sure how to use it. The issue is the height is dyamic. Below is the component and styling
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all
I'm trying to implement a bookmark feature, that will scroll to a certain index when opening the list.
I am faced with 2 issues and would like some help.
One is the best way of doing scrollTo. Should I use the ref function or the prop. With the ref function, I had to do the below to make it work but I'm not sure if there is a better way.
The second and main issue is that the scrolling to the bookmarked verse is inconsistent.
Somethimes it will land quite a few indexes away from the target.
I was told to use the overrideItemLayout but I'm not sure how to use it. The issue is the height is dyamic. Below is the component and styling
Beta Was this translation helpful? Give feedback.
All reactions