import React from "react"; import {fetchNews} from "../../../api/news"; import Group from "../../../ui/Group/Group"; import {Link} from "react-router-dom"; type Props = { path: string }; type State = { news: PostType[] }; class APNews extends React.Component { state: State = { news: [] } componentDidMount() { fetchNews().then(news => this.setState({ news })); } render() { const { news } = this.state; const { path } = this.props; return ( {news.map(post => (
{post.id}
{post.title}
))}
) } } export default APNews;