Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7463 | Rev 7786 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
7459 stevensc 1
import React, { useEffect } from "react";
7205 stevensc 2
import FeedTemplate from "./FeedTemplate";
7458 stevensc 3
import { fetchFeeds, setCurrentPage } from '../../redux/feed/feed.actions'
4
import { useDispatch, useSelector } from "react-redux";
5
import PaginationComponent from "../../shared/PaginationComponent";
7161 stevensc 6
 
7458 stevensc 7
const FeedSection = React.memo(() => {
7205 stevensc 8
 
7458 stevensc 9
  const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(state => state.feed);
7463 stevensc 10
 
7458 stevensc 11
  const dispatch = useDispatch()
7205 stevensc 12
 
7458 stevensc 13
  useEffect(() => {
14
    dispatch(fetchFeeds(timelineUrl, currentPage))
7467 stevensc 15
    console.log(timelineUrl)
16
  }, [timelineUrl]);
7458 stevensc 17
 
18
 
19
  const onChangePageHandler = (currentPage) => {
20
    dispatch(setCurrentPage(currentPage))
21
    dispatch(fetchFeeds(timelineUrl, currentPage))
22
    window.scrollTo(0, 0);
23
  };
24
 
7235 stevensc 25
  if (loading) {
26
    return <h6>Loading...</h6>
7221 stevensc 27
  }
28
 
7235 stevensc 29
 
7154 stevensc 30
  return (
7232 stevensc 31
    <>
32
      {
7458 stevensc 33
        allFeeds.map((feed) =>
7232 stevensc 34
          <FeedTemplate
35
            feed={feed}
36
            key={feed.feed_unique}
37
          />
38
        )
39
      }
7458 stevensc 40
      <PaginationComponent
41
        onChangePage={onChangePageHandler}
42
        pages={pages}
43
        isRow
44
        currentActivePage={currentPage}
45
      />
7232 stevensc 46
    </>
7205 stevensc 47
  );
7235 stevensc 48
});
7205 stevensc 49
 
7154 stevensc 50
export default FeedSection