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.

Calling scrollToRow() on List no longer works after updating React to v16.4.1

See original GitHub issue

I have a fairly complicated app where this issue is occurring, so it is not so easy to include a simple example showing the problem. Essentially what I am doing is calling

this._pdfView.getWrappedInstance().list.scrollToRow(index);

where this._pdfView is a ref to a connected component (hence the getWrappedInstance() call), which in turn has a getter to access the ref to a List component. I use a combination of WindowScroller, AutoSizer and List. Important to note is that this is an issue specifically with React v16.4.1. If I revert to React v16.3.0 everything works like expected.

If this information is not sufficient, I will try to attach a minimal example that reproduces the problem. I understand that otherwise it will be difficult for you to track down the problem.

What is the current behavior?

Calling scrollToRow() no longer scrolls to the right row. In fact, it doesn’t seem to be doing anything anymore.

What is the expected behavior?

It should scroll to the row given by the index.

Which versions of React and react-virtualized, and which browser / OS are affected by this issue? Did this work in previous versions of react-virtualized?

Browser Chrome v67
OS OSX 10.13.6
React 16.4.1
React DOM 16.4.1
react-virtualized 9.20.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
stephane71commented, Aug 7, 2018

Hi,

I have the same problem with the scrollToPosition and React 16.4.

Here is what I have found: A bug fix has been done on React 16.4 on the getDerivedStateFromProps, see https://reactjs.org/blog/2018/05/23/react-v-16-4.html#bugfix-for-getderivedstatefromprops

The important part is:

getDerivedStateFromProps is now called every time a component is rendered, regardless of the cause of the update. Previously, it was only called if the component was re-rendered by its parent, and would not fire as the result of a local setState.

Here is the code from React Virtualized Grid in the getDerivedStateFromProps https://github.com/bvaughn/react-virtualized/blob/c646a62eb3f7aebdfe648bb71cb87545af4d3a9b/source/Grid/Grid.js#L839-L845

The nextProps.scrollTop always erase the new value of prevState.scrollTop because it’s not anymore the previous state but the new one.

8reactions
evgenii-eremeevcommented, Dec 14, 2018

I’ve made a PR which should fix this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scrollToIndex doesn't scroll the list in React-virtualized list
You can use the scrollToCell or scrollToRow method (depending on whether you're using Grid or List/Table) to re-scroll to the same index.
Read more >
react-virtualized | Yarn - Package Manager
React components for efficiently rendering large, scrollable lists and tabular data ... The following wonderful companies have sponsored react-virtualized:.
Read more >
Redux Fundamentals, Part 5: UI and React
No matter what UI layer you're using, Redux works this same way with ... All we have to do is call useSelector() once...
Read more >
React v16.0 – React Blog
render() { // No need to wrap list items in an extra element! return [ // Don't ... To address this problem, React...
Read more >
Releases - styled-components
Update css-to-react-native to v3.0.0 (#2811); the one breaking change noted is that unitless line height is no longer allowed when setting font properties....
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