react-infinite-scroll-component icon indicating copy to clipboard operation
react-infinite-scroll-component copied to clipboard

scrollableTarget using refs / document.getElementsByClassName

Open riddhiparekh opened this issue 5 years ago • 2 comments

Hi, i am having trouble with multiple scrolls issue. I am wrapping infinitescroll component within react-perfect-scrollbar component for styling. But unfortunately it does not provides option to pass id.

<PerfectScrollbar ref="scrollableref">
      <InfiniteScroll
        dataLength={this.state.devices.length}
        next={this.fetchData.bind(this)}
        hasMore={this.state.hastNext}
        loader={<div className="loading"><T.span text="common.loading" /></div>}
        scrollableTarget={this.refs.scrollableref}
      />
</PerfectScrollbar >

How can i set scrollableTarget to perfect scrollbar div? As currently on scroll it is not loading data for next batch.

riddhiparekh avatar Mar 26 '20 18:03 riddhiparekh

Did you find a solution for that?

cagrispan avatar Feb 17 '21 11:02 cagrispan

You can try something like this:

const myRef = useRef(null);
<div ref={myRef}> 
   <InfiniteScroll key={myRef.current} scrollableTarget={myRef.current} />
</div>

Krknv avatar Feb 28 '22 09:02 Krknv