W
W
wini6662017-08-23 21:58:03
React
wini666, 2017-08-23 21:58:03

How to load content on scroll in React/Redux?

How to load content on scroll with React/Redux? There is an action with loading cards from the API, it has arguments with limit, skip, but how to attach scroll to this, how will it understand that it is scrolled to the bottom of the page and is it time to make a new request for the next cards in the list? Maybe there are packages that make life easier with this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Alexandrovich, 2017-08-23
@wini666

try it

$(window).on('scroll', function(){
    if( $(window).scrollTop() > $(document).height() - $(window).height() ) {
        //вызов апи
    }
}).scroll();

Only I think that it will be necessary to add eventListener to compontWillMount. And it is better to look for something already ready. https://cassetterocks.github.io/react-infinite-scr... here is a very good option. Easily integrated and understandable scroller. it has a lot of variations.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question