Proyectos de Subversion LeadersLinked - Backend

Rev

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