Rev 14867 | 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 = () => {
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 React.memo(FeedSection)