Rev 7463 | Rev 7794 | 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";
const FeedSection = React.memo(() => {
const { allFeeds, timelineUrl, pages, currentPage, loading } = useSelector(state => state.feed);
const dispatch = useDispatch()
useEffect(() => {
dispatch(fetchFeeds(timelineUrl, currentPage))
console.log(timelineUrl)
}, [timelineUrl]);
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