reactjs - window.scrollTo() in react components? -
where have put window.scrollto(0,0)
call in react component?
i tried put directly render
, tried componentdidupdate
(to wait till rendered), somehow the scrollbars stay @ same position.
-- edit --
the problem css height/overflow of window , body.
well, window.scrollto(0,0) stick top of page.
you correct in saying code should live in componentdidmount function, need tell scroll. locate id of element want scroll , obtain it's y coordinates, enter window.scrollto , should work. may need height of component , add dymamic value obtained.
Comments
Post a Comment