Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 7235 | Rev 7459 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 7235 Rev 7458
Línea 1... Línea 1...
1
import React from "react";
1
import React from "react";
2
import useDataFetching from "../../hooks/useDataFetching";
-
 
3
import FeedTemplate from "./FeedTemplate";
2
import FeedTemplate from "./FeedTemplate";
-
 
3
import { fetchFeeds, setCurrentPage } from '../../redux/feed/feed.actions'
-
 
4
import { useDispatch, useSelector } from "react-redux";
-
 
5
import PaginationComponent from "../../shared/PaginationComponent";
Línea 4... Línea 6...
4
 
6
 
Línea 5... Línea 7...
5
 
7
 
-
 
8
const FeedSection = React.memo(() => {
-
 
9
 
-
 
10
  const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(state => state.feed);
-
 
11
  const dispatch = useDispatch()
-
 
12
 
-
 
13
  useEffect(() => {
-
 
14
    dispatch(fetchFeeds(timelineUrl, currentPage))
-
 
15
  }, []);
-
 
16
 
-
 
17
 
-
 
18
  const onChangePageHandler = (currentPage) => {
-
 
19
    dispatch(setCurrentPage(currentPage))
Línea 6... Línea 20...
6
const FeedSection = React.memo(({ timeLineUrl }) => {
20
    dispatch(fetchFeeds(timelineUrl, currentPage))
7
 
21
    window.scrollTo(0, 0);
8
  const { error, loading, results } = useDataFetching({ url: timeLineUrl, params: { page: 1 } })
22
  };
Línea 9... Línea -...
9
 
-
 
10
  if (loading) {
-
 
11
    return <h6>Loading...</h6>
-
 
Línea 12... Línea 23...
12
  }
23
 
13
 
24
  if (loading) {
14
  if (error) {
25
    return <h6>Loading...</h6>
15
    <p>{error.message}</p>
26
  }
16
  }
27
 
17
 
28
 
18
  return (
29
  return (
19
    <>
30
    <>
20
      {
31
      {
21
        results.current?.items.map((feed) =>
32
        allFeeds.map((feed) =>
-
 
33
          <FeedTemplate
-
 
34
            feed={feed}
-
 
35
            key={feed.feed_unique}
-
 
36
          />
-
 
37
        )
-
 
38
      }
22
          <FeedTemplate
39
      <PaginationComponent
23
            feed={feed}
40
        onChangePage={onChangePageHandler}
24
            key={feed.feed_unique}
41
        pages={pages}
Línea 25... Línea 42...
25
          />
42
        isRow
26
        )
43
        currentActivePage={currentPage}