question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

scrollableTarget not trigger

See original GitHub issue

Hi !! I am having some trouble with scrollableTarget prop. When I set the prop, the next function never gets triggered. It seems that I am doing something wrong but I can’t see what …

Here is some part of my code:

<Grid.Column width={11} id='billList' className='bill-content fdx-content bill-list-container'>
              <InfiniteScroll
                dataLength={this.props.bills.length} //This is important field to render the next data
                next={this.loadBills}
                scrollableTarget={document.getElementById('billList')}
                onScroll={()=> {console.log(document.getElementById('billList'))}}
                hasMore={this.state.hasMore}
                loader={<Loader status={this.props.isFetching} />}
                endMessage={
                  <p style={{textAlign: 'center'}}>
                    <b>Yay! You have seen it all</b>
                  </p>
                }>
                  <BillList
                    localId={local.id}
                    token={token}
                    getBills={getBills}
                    openSidebar={this.openSidebar}
                    isSidebarOpen={isSidebarOpen}
                    bills={this.props.bills}
                  />
                </InfiniteScroll>
            </Grid.Column>

I have a ‘Grid’ parent div which has billList as ID. This means that the InfiniteScroll is not working with the div scroll. Besides, if I set a particular height to the InifniteScroll component the onScroll function logs all actions.

I have also looked for some examples with the scrollableTarget option working, but it seems that there is any one in the repo.

I hope you can help me !!

Guido

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
ankeetmainicommented, May 16, 2018

Please find a working sample here https://codesandbox.io/s/r7rp40n0zm

Instead of passing the node reference like document.getElementById("some-div") just pass the id of the DOM element.

1reaction
ankeetmainicommented, May 17, 2018

No no, so giving an id to Grid.Column will not work, id should be on a DOM node. Grid.Column won’t set id to any element. So when InfiniteScroll component does document.getElementById(‘billList’) it’ll not get anything.

Can’t you pass a height, or let the scroll happen at the window?

On Thu, 17 May 2018 at 18:01 Guido notifications@github.com wrote:

Yes

<Grid.Column width={11} id=‘billList’ className=‘bill-content fdx-content bill-list-container’> <InfiniteScroll dataLength={this.props.bills.

length} //This is important field to render the next data next={this.loadBills} scrollableTarget=“billList” hasMore={this.state.hasMore} loader={<Loader status={this.props.isFetching} />}> <BillList localId={local.id} token={token} getBills={getBills} openSidebar={this.openSidebar} isSidebarOpen={isSidebarOpen} bills={this.props.bills} /> </InfiniteScroll> </Grid.Column>

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59#issuecomment-389849721, or mute the thread https://github.com/notifications/unsubscribe-auth/AGWDl6hOFrJ9yZEb_bXGKQqMtQu0RTipks5tzW2NgaJpZM4T6QeI .

Read more comments on GitHub >

github_iconTop Results From Across the Web

next prop not working in react-infinite-scroll-component
i tried giving id="scrollableDiv" to every div in the page and also <html> in index.html still no use. when i remove the scrollableTarget=" ......
Read more >
react-infinite-scroll-component - npm
An Infinite Scroll component in react.. Latest version: 6.1.0, last published: 2 years ago. Start using react-infinite-scroll-component in ...
Read more >
React-infinite-scroll-component NPM - npm.io
infinite scroll with scrollableTarget (a parent element which is scrollable) ... It must trigger some sort of action which fetches the next data....
Read more >
How to setup Infinite Scroll in your react component?
This is one of the most important prop, We pass a loadMoreData function to it that triggers some action which fetches the next...
Read more >
react-infinite-scroll-component | Yarn - Package Manager
</h4>} scrollableTarget="scrollableDiv" > {this.state.items.map((_, index) => ( <div ... It must trigger some sort of action which fetches the next data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found