Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get ref of the ScrollArea component? #116

Open
joetidee opened this issue Apr 22, 2018 · 2 comments
Open

How to get ref of the ScrollArea component? #116

joetidee opened this issue Apr 22, 2018 · 2 comments

Comments

@joetidee
Copy link

I want to get a reference to the ScrollArea component, in order to obtain various information about the scroll position. I cannot use the supplied onScroll function. So how do I get a ref, as when I do this...

ref={scrollArea => this.scrollArea = scrollArea}

and try and get the I get scrollTop...

const scrollTop = this.scrollArea.scrollTop;

I get an error:

Uncaught TypeError: Cannot read property 'scrollTop' of null

@tnrich
Copy link

tnrich commented Nov 5, 2018

I'm also wondering how to do exactly this. Thanks!

@DiogoAbu
Copy link

Get ref:

const scrollRef = useRef(null);  // or the pre-hook way
<ScrollArea ref={scrollRef}>

then scroll:
scrollRef.current.scrollArea.scrollBottom();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants