import React, { useState } from 'react'; //DOCS: props.uri is the address of a live news-server const NewsFeed = props => { const [articles, setArticles] = useState(null); if (!articles) { fetch(props.uri, { method: 'GET' }) .then(a => { if (!a.ok) { throw `Network error ${a.status}: ${a.statusText} ${a.url}`; } return a.json(); }) .then(a => setArticles(a)) .catch(e => console.error(e)) ; } return (
{`${article.edits} edit${article.edits > 1 ? 's': ''}`}
: null }{article.body}