1 min readAug 29, 2018
componentDidUpdate() {
let hash = this.props.location.hash.replace('#', '');
if (hash) {
let node = ReactDOM.findDOMNode(this.refs[hash]);
if (node) {
node.scrollIntoView();
}
}
}
Then set a ref like this:
<h3 ref='scroll_here'>Scroll to here</h3>
Then you can just add #scroll_here
to the end of your URL.
Found it on Reddit and so far this is the best solution yet