Setting the scrollTop property of a React node is not working.
I'm trying to restore the scroll position of a list when navigating to and from the page with the list.
Currently my code is the following:
componentDidMount() {
let prevScrollHeight = Number(localStorage.getItem('listHeight'));
if (prevScrollHeight >= 0) {
let listNode = ReactDOM.findDOMNode(this.refs.speakersList);
listNode.scrollTop = prevScrollHeight;
}
}
The scroll height is successfully being stored in local storage. What's not working is: listNode.scrollTop = prevScrollHeight
Does anyone know how I can set the scroll position of a React node?