Skip to content

Simple and fast application wrapper with already built event management

Notifications You must be signed in to change notification settings

pedrobullo/react-infinite-scroll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

React Infinite Scroll

Clean and fast scroll listener wrapper component with callback

props:

  • scrollFunc (function): callback. (required)
  • scrollAnchor (string): element to listen scroll event. (default: window)
  • loading (bool): flag to prevent multiple callback triggers (default: false)
import infiniteScrollify from '...'

Example - Wrapping up

const PostList = ({ posts }) => (
  <ul>{posts.map(post => <li>{post.title}</li>)}</ul>
)
export default infiniteScrollify(PostList);

Rendering - Simple

<PostList posts={posts} scrollFunc={this.handleFetch()} />

Example - with Redux

class App extends React.Component {
  // ...
  <PostList posts={this.props.posts} loading={this.props.loading} />
  // ...
}

const mapStateToProps = state => ({
  posts: state.posts.list,
  loading: state.posts.isLoading
});

const mapDispatchToProps = {
  scrollFunc: () => fetchPosts(), // scrollFunc callback prop is required
};

export default connect(mapStateToProps, mapDispatchToProps)(infiniteScrollify(App));

TODOS

  • Tests
  • npm

About

Simple and fast application wrapper with already built event management

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published