2.0.2 • Published 3 years ago

react-infinite-scroll-reverse v2.0.2

Weekly downloads
83
License
MIT
Repository
github
Last release
3 years ago

REACT INFINITE SCROLL REVERSE COMPONENT

How to use

import InfiniteScrollReverse from "react-infinite-scroll-reverse";

In your component

const [isLoading, setIsLoading] = useState(true);
const [itemsList, setItemsList] = useState([]);
const itemsListTotal = 100500;

function getItems(page) {
  setIsLoading(true);
  setTimeout(() => {
    setItemsList(prev => ([...prev, { id: `uniq${page}`, name: "Alex" }]));
    setIsLoading(false);
  }, 300)
}

useEffect(()=>{
  getItems(1);
}, [])

  
<InfinteScrollReverse
  className="itemsContainer"
  hasMore={itemsList.length < itemsListTotal}
  isLoading={isLoading}
  loadMore={getItems}
  loadArea={30}
>
  {itemsList.map(item => (
    <div key={item.id}>{item.name}</div>
  ))}
</InfinteScrollReverse>

Props

NameTypeDefaultisRequiredDescription
classNameStringInfiniteScrollReversefalseClass name of scroll container with overflow
hasMoreBooleanfalsetrueHas more triger
isLoadingBooleanfalsetrueData fetching triger, must be true when data is loading
loadMoreFunctiontrueLoad more function
loadAreaIntager30falseScroll area on top. Run loadMore function
2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago