1.0.9 • Published 3 years ago
react-infinite-list-observer v1.0.9
react-infinite-list-observer
Demo
install
npm install react-infinite-list-observeror
yarn add react-infinite-list-observerusage
const listRef = useRef<ListHandler>(null);
const onSomething = () => {
if (listRef.current) {
listRef.current.resetPage();
listRef.current.scrollToTop();
}
]
<List
ref={listRef}
hasMore={hasMore}
list={items}
height={400} // optional
onFetchMore={fetchMore}
renderItem={(item) => {
return (
<div key={item.id}>{item.name}</div>
);
}}
/>#props
| Prop | description |
|---|---|
| list | T |
| renderItem | method returns JSX |
| hasMore | boolean |
| onFetchMore | method used to fetch more data |
| currentPage | optional - number |
| height | optional - number |
| className | used for styling |
| ref | optional: attach ref - allows you to reset the page / scroll to top |