-
Beta Was this translation helpful? Give feedback.
Answered by
idiotWu
Feb 14, 2022
Replies: 1 comment 3 replies
-
Not familiar with react, but I don't think keeping a reference to the scrollbar instance will consume too much memory because the instance always exists unless you destroy the scrollbar via Regarding your code, as the scrollbar is constructed when useLayoutEffect(() => {
const scrollbar = Scrollbar.init(...);
scrollbar.setPosition(0, 0); // you can use `.setPosition(0, 0)` instead of `.scrollTo(0, 0, 0)` to reset position
return () => scrollbar.destroy(); // destroy it if necessary
}, [router]); |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
blitzve0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not familiar with react, but I don't think keeping a reference to the scrollbar instance will consume too much memory because the instance always exists unless you destroy the scrollbar via
.destroy()
method.Regarding your code, as the scrollbar is constructed when
router
changes, I think we can simplify it as: