react-infinite-scroll-component
react-infinite-scroll-component copied to clipboard
scrollableTarget using refs / document.getElementsByClassName
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.
Did you find a solution for that?
You can try something like this:
const myRef = useRef(null);
<div ref={myRef}>
<InfiniteScroll key={myRef.current} scrollableTarget={myRef.current} />
</div>