Coder Social home page Coder Social logo

Comments (16)

lsvargas avatar lsvargas commented on July 24, 2024 3

@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.

ankeetmaini avatar ankeetmaini commented on July 24, 2024

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.

rajivhbk avatar rajivhbk commented on July 24, 2024

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.

rajivhbk avatar rajivhbk commented on July 24, 2024

@lsvargas any progress on this issue?

from react-infinite-scroll-component.

ankeetmaini avatar ankeetmaini commented on July 24, 2024

@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.

rajivhbk avatar rajivhbk commented on July 24, 2024

@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.

ankeetmaini avatar ankeetmaini commented on July 24, 2024

from react-infinite-scroll-component.

rajivhbk avatar rajivhbk commented on July 24, 2024

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.

kumawatanupriya avatar kumawatanupriya commented on July 24, 2024

@rajivhbk Did you solve it? I am also facing the same issue, I am using react infinite scroll.

from react-infinite-scroll-component.

moecantplay avatar moecantplay commented on July 24, 2024

i am facing the same issue where scrollableTarget isn't working as expected.

from react-infinite-scroll-component.

aakin03 avatar aakin03 commented on July 24, 2024

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.

missingone6 avatar missingone6 commented on July 24, 2024

Hello, have you solved it yet

from react-infinite-scroll-component.

shurintou avatar shurintou commented on July 24, 2024

@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.

osamamammar avatar osamamammar commented on July 24, 2024

@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.

murilooon avatar murilooon commented on July 24, 2024

Same problem inside an Ant design Drawer component 😞

from react-infinite-scroll-component.

 avatar commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.