import React, { useState, useEffect } from 'react';
import Router, { withRouter } from 'next/router'
// @material-ui/core components
import { makeStyles } from "@material-ui/core/styles";
import ReactPaginate from 'react-paginate';
// component
import styles from "assets/jss/nextjs-material-kit/pages/componentsSections/notificationsStyles.js";
import Paper from '@material-ui/core/Paper';
import Grid from '@material-ui/core/Grid';
import GridContainer from "components/Grid/GridContainer.js";
import Card from "components/Card/Card.js";
import CardBody from "components/Card/CardBody.js";
import Button from "components/CustomButtons/Button.js";
import Paginations from "components/Pagination/Pagination.js";
import Icon from "@material-ui/core/Icon";
const useStyles = makeStyles(styles);
const DataLatestNews = function ({ backend, news, ...props }) {
const [isLoading, setLoading] = useState(false); //State for the loading indicator
const startLoading = () => setLoading(true);
const stopLoading = () => setLoading(false);
useEffect(() => { //After the component is mounted set router event handlers
Router.events.on('routeChangeStart', startLoading);
Router.events.on('routeChangeComplete', stopLoading);
return () => {
Router.events.off('routeChangeStart', startLoading);
Router.events.off('routeChangeComplete', stopLoading);
}
}, [])
const pagginationHandler = (page) => {
const currentPath = props.router.pathname;
const currentQuery = props.router.query;
currentQuery.page = page.selected + 1;
props.router.push({
pathname: currentPath,
query: currentQuery,
});
};
const classes = useStyles();
const latnews = news.map((data) => {
return (
{data.title}
{data.title}
*/}