// IMPORT MODULES import React, { useState, useEffect } from "react"; import { Link } from "react-router-dom"; import axios from "axios"; import i18n from '../i18n'; import '../i18n'; import { withTranslation } from 'react-i18next'; // IMPORT COMPONENTS import Breadcrumb from "../components/Global/Breadcrumb"; // TAB_1 // import RightArrowBlue from "../svg/rightArrowBlue.svg"; // import TabIMG1 from "../img/tabImg_1.jpg"; class News extends React.Component { _isMounted = false; constructor(props) { super(props); this.state = { items: [], DataisLoaded: false }; } // useEffect(() => { // window.scrollTo(0, 0); // }, []); // STATE // const [pageIndex, setPageIndex] = useState(1); componentDidMount() { this.getTodos(); } async getTodos() { this._isMounted = true; await axios.get('http://127.0.0.1:8000/api/v1/categories/2') .then(res => { const items = res.data; if (this._isMounted) { this.setState({ items: items, DataisLoaded: true }); this._isMounted = false; console.log(this.state.items['data'][0]['posts']); } }) // console.log('salam'); // console.log(this.state.items['data']); } componentWillUnmount() { console.log("novosti gutardy"); } render() { const { DataisLoaded, items } = this.state; if (!DataisLoaded) return