npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

redux-lazy-scroll

v0.1.1

Published

React/Redux infinite/lazy scrolling/loading functionality.

Downloads

1,674

Readme

npm version Heroku

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 client side and server/api side
  • 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


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

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