Get div's offsetTop positions in React

前端 未结 6 916
暗喜
暗喜 2021-01-30 08:08

I am trying to implement a List view in React. What I am trying to achieve is that to store the list headers informations and register the components and register the scroll ev

6条回答
  •  灰色年华
    2021-01-30 08:43

    A better solution with ref to avoid findDOMNode that is discouraged.

    ...
    onScroll() {
        let offsetTop  = this.instance.getBoundingClientRect().top;
    }
    ...
    render() {
    ...
     this.instance = el } />
    ...
    

提交回复
热议问题