I have two divs on the page side by side and the left one is a stateless component showing the information regarding the option selected from the right side.
The page itself has overflow: hidden
and the left side component has overflow-y: scroll
allowing the user to scroll down and up.
Until here everything is good however when the user scrolls down and then select another piece in the right side, I should scroll this stateless component up.
return (
<div
style='display: flex; flex: 1 1 0; height: 100%; overflow-y: scroll'
ref={myElement => {
this.myElement = myElement
}}
>
My content
</div>
)
And once we have a ref on this element, I could have something like this:
this.myElement.scrollTop = 0
I am trying to put a ref in this div to be able to scroll once this component receives any update as https://stackoverflow.com/a/33204783/1696029 but the ref does not work with stateless component.
Any ideas how can I scroll up only this left stateless component?