onScroll not called when scrollTarget is a react component after unmount/remount
juhaelee opened this issue · comments
I found that the the onScroll
handler is not being called when the scrollTarget is a react component and the component gets unmounted (then later again mounted). The use case for this is when you're using something like react-router and you click the back button and the component unmounts, and you go back to the route, and the component remounts. The FastScroll.getInstance
is retrieving an instance that doesn't exactly match the previously unmounted react component.
A potential fix for this could be to clear the instance on componentWillUnmount if the scrollTarget is a react component? https://github.com/soenkekluth/react-sticky-state/blob/master/index.js#L437
@juhaelee you are right. the problem is solved by the current version