react-infinite-scroller icon indicating copy to clipboard operation
react-infinite-scroller copied to clipboard

make option `element` of type `elementType`

Open robsdedude opened this issue 6 years ago • 2 comments

I'm using material-ui and I want the scroll container to be a Grid node. So I did

import { Grid } from "@material-ui/core";
...
<InfiniteScroll
  loadMore={loadMore}
  hasMore={hasNextPage}
  loader={<p>Loading...</p>}
  element={Grid} container spacing={3}
>
...

which works great. Note that container and spacing are props that are passed down to the Grid component.

The only problem is that I get a warning in the dev console:

Warning: Failed prop type: Invalid prop `element` supplied to `InfiniteScroll`, expected a ReactNode.

This could easily be fixed by changing

InfiniteScroll.propTypes = {
  ...
  element: _propTypes2.default.node,
  ...
};

to

element: _propTypes2.default.elementType

robsdedude avatar Sep 08 '19 20:09 robsdedude

why is this issue being ignored for so long?

if it helps anyone, I added this to my code:

delete InfiniteScroller.propTypes.element;

iMoses-Apiiro avatar Jun 15 '22 10:06 iMoses-Apiiro

Someone has even made a PR for that: https://github.com/danbovey/react-infinite-scroller/pull/228

@danbovey Any chance for merging & releasing?

villesau avatar Sep 02 '23 19:09 villesau