# redux-lazy-scroll

> React/Redux infinite/lazy scrolling/loading functionality.

Latest version **0.1.1** (published 2017-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-lazy-scroll
pnpm add redux-lazy-scroll
yarn add redux-lazy-scroll
bun add redux-lazy-scroll
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2017-10-11 |
| First published | 2017-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Shota Karkashadze |
| Maintainers | shotak |
| Keywords | React, Redux, infinite scroll, lazy loading, redux infinite loading, react lazy loader, async intinite scroll |

## Links

- npm: https://www.npmjs.com/package/redux-lazy-scroll
- Repository: https://github.com/shotaK/redux-lazy-scroll
- Issues: https://github.com/shotaK/redux-lazy-scroll/issues
- npm.io page: https://npm.io/package/redux-lazy-scroll

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2017-10-11
- 0.1.0 — 2017-10-09
- 0.0.1 — 2017-10-07
- 1.0.0 — 2017-09-23

## README

[![npm version](https://badge.fury.io/js/redux-lazy-scroll.svg)](https://badge.fury.io/js/redux-lazy-scroll)
![Heroku](http://heroku-badge.herokuapp.com/?app=ancient-sands-71156&style=flat&svg=1)

# Redux Lazy Scroll

React/Redux lazy scrolling functionality with full Redux implementation example.

## Features

* Scrollable inside element or window
* Compatible with async requests
* All of the retrieved data is persisted in Redux, thus the library obeys single source of truth principle
* Comes with a full implementation example of both <a href="https://github.com/shotaK/redux-lazy-scroll/tree/master/dev/client" target="_blank">client side</a> and <a href="https://github.com/shotaK/redux-lazy-scroll/tree/master/dev/server" target="_blank">server/api side</a>
* For flexibility the library does not contain any built in textual messages (for example: loading or error messages). Examples how to add them are provided.

## Demo

You can see the demo here: https://ancient-sands-71156.herokuapp.com/

## Installation

```npm install redux-lazy-scroll --save```

## Usage

```javascript

class PostsLazyScroll extends Component {

  constructor(props) {
    super(props);
    this.loadPosts = this.loadPosts.bind(this);
  }

  loadPosts() {
    const {skip, limit} = this.props.postEntity;
    this.props.postsActions.fetchPosts(skip, limit);
  }

  render() {
    const {posts, isFetching, errorMessage, hasMore} = this.props.postEntity;
    return (
      <div className="container posts-lazy-scroll">
        <ReduxLazyScroll
          isFetching={isFetching}
          errorMessage={errorMessage}
          loadMore={this.loadPosts}
          hasMore={hasMore}
        >
          {posts.map(post => (
            <Post
              key={post._id}
              post={post}
            />
            ))
          }
        </ReduxLazyScroll>
        <div className="row posts-lazy-scroll__messages">
          {isFetching && <div className="alert alert-info"> Loading more posts... </div>}

          {!hasMore && !errorMessage &&
            <div className="alert alert-success">All the posts has been loaded successfully.</div>
          }

          {errorMessage && <div className="alert alert-danger">{errorMessage}</div>}
        </div>
      </div>
    );
  }
}

```

## Examples

You can find full Redux example [here](https://github.com/shotaK/redux-lazy-scroll/tree/master/dev/client/posts)

## Props

| Props         | Type           | Required  | Default  | Description |
| ------------- |:--------------:| :--------:| :-------:| :----------:|
| hasMore       | bool           | no        | true     | Whether there are more items that will be coming with the next request |
| isFetching    | bool           | no        | false    | Should be set true while a request to api is being processed |
| errorMessage  | string or bool | no        | false    | Supply any error message that came from the api with this prop (this will help to avoid infinite loops in case of error) |
| loadMore      | func           | no        | () => {} | The function that will be called after every scroll down when threshold is passed (will be only called if `hasMore` is true) |
| threshold     | number         | no        | 100      | The number of pixels above the bottom side of the page that scrollbar needs to reach to trigger loadMore |
| isParentScrollable | bool      | no        | false    | Whether the scroll listener should be attached to the parent element or window |
| parentHeight  | number or string | if `isParentScrollable` is `true` | false | The height of the container parent element. Must be set if `isParentScrollable` is `true` |

## License

MIT License. Copyright (c) 2017 Shota

---
_Source: https://npm.io/package/redux-lazy-scroll · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
