react-infinite-scroll-component icon indicating copy to clipboard operation
react-infinite-scroll-component copied to clipboard

Set height automatically according to parent's available height

Open lbssousa opened this issue 4 years ago • 3 comments

I have an InfiniteScroll component inside a CSS Grid cell (typical layout: Header, Main, Aside and Footer), like in screenshot below: photo_2021-07-16_12-26-39

I want to avoid vertical overflow of my grid, so I can still have my fixed footer while getting infinite scroll working. The only way I've found to achieve this is setting the prop height of my InfiniteScroll component.

My question is: how can I get the height of the parent element (in the case of screenshot above, 763px) and set it to height prop of my InfiniteScroll component? Or is there another way to let InfiniteScroll grow automatically to fit its parent height?

lbssousa avatar Jul 16 '21 15:07 lbssousa

Perhaps the outerDiv should inherit display, flexDirection, flexGrow and height so it doesn't assume it's own layout?

jmbldwn avatar Aug 22 '21 17:08 jmbldwn

@jmbldwn - can you expand on this? Some example code might be helpful. I am struggling with the same issue. Just can't get fetching to work properly without explicitly setting the height of the parent div.

DonAyers avatar Sep 14 '21 15:09 DonAyers

I decided to use the material-ui data grid instead, but looking at this, it looks like the outer div has a class name, which could be used to give it some css love to inherit height from it's parent:

      <div
        style={outerDivStyle}
        className="infinite-scroll-component__outerdiv"
      >

jmbldwn avatar Sep 14 '21 17:09 jmbldwn