Comments (10)
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.
from react-infinite-scroll-component.
from react-infinite-scroll-component.
Have same problems
from react-infinite-scroll-component.
I see, I debugged this and seems like by the time your component's render gets called, the element doesn't exist in the DOM. It then passes null, as scrollableTarget, because document.getElementId('some-div') doesn't return anything.
To fix this I'll add another check to see if scrollableTarget's type is string, I'll do a lookup from the DOM inside InfiniteScroll's componentDidMount.
from react-infinite-scroll-component.
@ankeetmaini I have updated the package but when i put the scrollableTarget as a string it breaks all the webapp
<InfiniteScroll
dataLength={this.props.bills.length}
next={this.loadBills}
hasMore={this.state.hasMore}
scrollableTarget="billList"
loader={<Loader status={this.props.isFetching} />} >
<BillList
localId={local.id}
token={token}
getBills={getBills}
openSidebar={this.openSidebar}
isSidebarOpen={isSidebarOpen}
bills={this.props.bills}
/>
</InfiniteScroll>
from react-infinite-scroll-component.
from react-infinite-scroll-component.
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>
from react-infinite-scroll-component.
Yes you are right. If I put the ID in a Grid element it doesnt works. But if I change it to a div it works. Thanks for your work 🥇
from react-infinite-scroll-component.
Hello thanks for this plugin, i have a question.
what if the infinite-scroll-component is rendered inside a shadow dom and also the scollableTarget is in the shadow dom?
If the id of the scollableTarget is passed then the id is relative to the shadow dom and not the main document, so calling document.getElementById("Myid") will result in null, instead if done inside the shadow dom the element is found.
there is a way to pass a ref to the component instead than the id, on an html element ?
from react-infinite-scroll-component.
Hello thanks for this plugin, i have a question.
what if the infinite-scroll-component is rendered inside a shadow dom and also the scollableTarget is in the shadow dom?
If the id of the scollableTarget is passed then the id is relative to the shadow dom and not the main document, so calling document.getElementById("Myid") will result in null, instead if done inside the shadow dom the element is found.
there is a way to pass a ref to the component instead than the id, on an html element ?
In fact, you can copy the component into your code and then replace document.getElementById with your own code.
from react-infinite-scroll-component.
Related Issues (20)
- Integration with Headless UI popover not working as expected.
- Block is appearing during scroll HOT 1
- Number 0 appears when finish loading message appears HOT 1
- `scrollableTarget` throws error `Type 'HTMLElement' is not assignable to type 'ReactNode'` in React 18 HOT 3
- Inverse does not work if you do not set a specific height
- Not calling next function on long screens HOT 13
- can not working in shadowDOM
- react-infinite-scroll-component is no longer maintained HOT 3
- The component is not working after a certain amount of items in the list
- Don't loading new content, if initial content height <= screen height HOT 4
- Please modify the npm docs and mention that for the dataLength prop we need to pass the actual length of the data that we are currently rendering.
- TypeError on latest Next.js HOT 4
- Bidirectional Infinite Scroll HOT 2
- Wrong calculation in isElementAtTop method causing percentage scrollThreshold to fail in inverse mode HOT 1
- Invalid Hook call on SetProgress -> 100%
- is this library supported horizontal scroll?
- 【IMPORT FOR EVERYONE】HOW TO FIX:Don't load new items when content height <= screen height
- Possibility to pass throttle time as props
- How can I change the scrollY when the InfiniteScroll has rendered HOT 1
- next function doesn't called HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-infinite-scroll-component.