react-stay-scrolled
react-stay-scrolled copied to clipboard
initialScroll doesn't work on first render
I've found that initialScroll: Infinity
doesn't quite work for the very first time my component renders, i.e. after a page refresh.
I think what's happening is that, during the very first render, domRef.current.scrollHeight
is 0 (I'm not sure why?), so the scroll bails out.
If I make my effect that calls stayScrolled
depend on the container height (maxScrollTop(domRef.current)
), it works.
Not sure if there's a better way or if I'm missing something.
If not, perhaps we could update the documentation to suggest this approach to ensure stayScrolled()
is called when the container height changes.
Hi, sorry for the late response, I was quite busy moving house ><;; Can you send me a repro of this issue?