Rev 7459 | Rev 7467 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
import React, { useEffect } from "react";
import FeedTemplate from "./FeedTemplate";
import { fetchFeeds, setCurrentPage } from '../../redux/feed/feed.actions'
import { useDispatch, useSelector } from "react-redux";
import PaginationComponent from "../../shared/PaginationComponent";
import useDataFetching from "../../hooks/useDataFetching";
const FeedSection = React.memo(() => {
const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(state => state.feed);
const { results } = useDataFetching({ url: timelineUrl, params: { pages: 1 } })
const dispatch = useDispatch()
useEffect(() => {
dispatch(fetchFeeds(timelineUrl, currentPage))
console.log(results)
}, []);
const onChangePageHandler = (currentPage) => {
dispatch(setCurrentPage(currentPage))
dispatch(fetchFeeds(timelineUrl, currentPage))
window.scrollTo(0, 0);
};
if (loading) {
return <h6>Loading...</h6>
}
return (
<>
{
allFeeds.map((feed) =>
<FeedTemplate
feed={feed}
key={feed.feed_unique}
/>
)
}
<PaginationComponent
onChangePage={onChangePageHandler}
pages={pages}
isRow
currentActivePage={currentPage}
/>
</>
);
});
export default FeedSection