S
S
Sergey Sofichev2018-10-12 12:54:21
React
Sergey Sofichev, 2018-10-12 12:54:21

How to use ScrollArea library methods inside a component?

There is a react-scrollbar library that has some methods (scrollYTo, scrollBottom, etc.).
The essence of the question: is it possible to use these methods in the addUser component?

...
import ScrollArea from 'react-scrollbar'
import UserList from './components/UserList'

class App extends Component {
  addUser = (e) => {
     //add user function
  }

  render() {
    return (
        <ScrollArea>
            <UserList />
        </ScrollArea>
          
    )
  }
}
...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
davidnum95, 2018-10-12
@davidnum95

import ScrollArea from 'react-scrollbar'
import UserList from './components/UserList'

class App extends Component {
  addUser = (e) => {
     this.scrollArea.scrollBottom();
  }

  render() {
    return (
        <ScrollArea ref={(ref) => this.scrollArea = ref}>
            <UserList />
        </ScrollArea>
          
    )
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question