Rev 7786 | Rev 14867 | 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 Spinner from "../../shared/Spinner";
import NotificationAlert from "../../shared/notification/NotificationAlert";
const FeedSection = React.memo(() => {
const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(state => state.feed);
const dispatch = useDispatch()
useEffect(() => {
dispatch(fetchFeeds(timelineUrl, currentPage))
}, [timelineUrl]);
const onChangePageHandler = (currentPage) => {
dispatch(setCurrentPage(currentPage))
dispatch(fetchFeeds(timelineUrl, currentPage))
window.scrollTo(0, 0);
};
if (loading) {
return <Spinner />
}
return (
<>
{
allFeeds.map((feed) =>
<FeedTemplate
feed={feed}
key={feed.feed_unique}
/>
)
}
<PaginationComponent
onChangePage={onChangePageHandler}
pages={pages}
isRow
currentActivePage={currentPage}
/>
<NotificationAlert />
</>
);
});
export default FeedSection