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.

How to perform action strictly after scrollToIndex has already finished?

See original GitHub issue

Firstly I just want you to know that before posting this issue, I tried asking on Stack Overflow to no avail. Here is the link to the unanswered post.

I also tried to access the Slack channel but was not authorized to log in.


I have a <List> component. I am building a feature where it:

  1. Scrolls to a particular row in the <List>. It does by using the scrollTo scrollToIndex prop.
  2. Scrolls to a particular line in that row. It does this by doing document.getElementById('myId').scrollIntoView().

How can I ensure that step (2) occurs after step (1)?

Note: I have already tried both onRowsRendered and onScroll but even using those callbacks, there is still a race condition between (2) and (1).

Here is the CodeSandbox link

Update: despite trying for a long time, I can’t actually get the CodeSandbox example to reproduce the race condition. I definitely am seeing such a race condition in my local instance, but since I can’t reproduce it, it’s probably a problem specific to my project 😢.

Please feel free to close the issue.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
wuweiweiwucommented, Apr 15, 2018

to answer your question. the onScroll prop you pass in is bound to the html onscroll event which is triggered every moment you scroll. The scrollToIndex prop is used to calculate the scrollTop and then is manually set on the html element.

So onScroll is actually not called when you just use scrollToIndex

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to scrollToIndex after the cells that will be visible ...
I want to wait for the cells that are going to visible to be rendered before scrolling to the position because right now...
Read more >
androidx.compose.ui.test - Android Developers
Only valid when a gesture has already been started, or when a finished gesture ... is a lazy container, it must support the...
Read more >
React Native scrollToIndex - Dynamic size item scroll inside ...
We'll go through: - What React Native scrollToIndex is - How to use ... Implement navigation +/- - 06:18 scrollToIndex when changing the ......
Read more >
React Native FlatList scrollToIndex with Fixed or Variable Row ...
In this video, I show you how to use the scrollToIndex function to scroll to a row with a certain index in a...
Read more >
[ScrollView] Add completion callback to scrollTo - React Native
... completion callback to execute something after the ScrollView has finished scrolling ... This is already implemented if you check with the source...
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