react-stay-scrolled icon indicating copy to clipboard operation
react-stay-scrolled copied to clipboard

initialScroll doesn't work on first render

Open mariaines opened this issue 4 years ago • 1 comments

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.

mariaines avatar Feb 25 '20 21:02 mariaines

Hi, sorry for the late response, I was quite busy moving house ><;; Can you send me a repro of this issue?

perrin4869 avatar Mar 04 '20 07:03 perrin4869