Comments (16)
@ankeetmaini sorry if i didnt make myself clear, I want next
to be called when my Table's scrollbar reaches the end, but what is actually happening in the code above is that next
is called when the main window scroll moves.
from react-infinite-scroll-component.
When the scrolling is on your main browser's window you don't need scrollableTarget at all. You can just make it working like this https://codesandbox.io/s/yk7637p62z
from react-infinite-scroll-component.
I tried passing reference to the parent element having scrollbars using React's create ref and forwardRef but it didn't work for me.
from react-infinite-scroll-component.
@lsvargas any progress on this issue?
from react-infinite-scroll-component.
@rajivhbk it won't work with refs because React renders children first and then parent. By the time InfiniteScroll mounts, the parent ref would be null.
To overcome this you can use id on your DOM element. Please see a working example here https://codesandbox.io/s/r7rp40n0zm
from react-infinite-scroll-component.
@ankeetmaini yes i tried that too . passing id, passing document.getElementById('id')..
didn't work for me. I'm using this component inside a sidepanel, the body of which has overflow-y: scroll , and height is calculated like : height: calc(100vh - 4.75rem) ... the body contains other components along with a table component which has a TableRows component placed inside infiniteScroll .
from react-infinite-scroll-component.
from react-infinite-scroll-component.
i passed it down to the div having the scrollbars as a prop from the component. i also tried giving an id directly to the div of the body component. Didn't work. It's a complicated implementation still i'll try to write an example to reproduce this.
from react-infinite-scroll-component.
@rajivhbk Did you solve it? I am also facing the same issue, I am using react infinite scroll.
from react-infinite-scroll-component.
i am facing the same issue where scrollableTarget isn't working as expected.
from react-infinite-scroll-component.
Hi, I know this issue has been closed, but are we still able to get a response?
I'm having a similar issue as many of those previously. I've set up InfinteScroll to wrap around a Table. InfinteScroll & Table are located inside of a TableContainer component. The TableContainer has an id which I used as the scrollableTarget
in InfinteScroll. In my main page, my table scrolls as expected with more data loading when I pass the threshold. However, when I try to use my table in a Dialog, InfinteScroll no longer works. When I scroll, I'm not reaching my next
function. How can InfinteScroll work while on a main window, but not when in a Dialog?
from react-infinite-scroll-component.
Hello, have you solved it yet
from react-infinite-scroll-component.
@aakin03 Hi, I'm facing same issue just as you mentioned, that scrollableTarget is not working while in a Dialog. (In my case I use Ant design Modal), have you solved this issue yet?
from react-infinite-scroll-component.
@aakin03 Hi, I'm facing same issue just as you mentioned, that scrollableTarget is not working while in a Dialog. (In my case I use Ant design Modal), have you solved this issue yet?
same problem have you solved it I'm using ant design Modal also
from react-infinite-scroll-component.
Same problem inside an Ant design Drawer component 😞
from react-infinite-scroll-component.
same issue for me too:
here is my code:
<Grid container spacing={3} id='scrollableDiv' style={{ height: 1000, overflow: 'auto' }}>
<InfiniteScroll
dataLength={postData.length}
next={fetchData}
inverse={true}
hasMore={true}
loader={
Loading...
}scrollableTarget='scrollableDiv'
>
{isLoading ? (
<Typography variant='h6'>Loading...</Typography>
) : postData ? (
postData.map(post => (
<Grid item key={post.id}>
<Card style={{ margin: '8px' }}>
<CardContent>
<Typography variant='h6'>{post.title}</Typography>
<Typography variant='body2'>{post.body}</Typography>
</CardContent>
</Card>
</Grid>
))
) : (
<Typography variant='h6'>No data available</Typography>
)}
</InfiniteScroll>
</Grid>
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 5
- 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 HOT 2
- Possibility to pass throttle time as props
- How can I change the scrollY when the InfiniteScroll has rendered HOT 2
- next function doesn't called HOT 3
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.