import React from 'react'; import withCache from './withCache'; import newsFecher from './newsFetcher'; import Placeholder from './Placeholder'; @withCache export default class News extends React.Component { static getDerivedStateFromProps = (nextProps, nextState) => ({ news: newsFetcher(nextProps.cache) }); render() { const { news } = this.state; return ( Loading..}> {news.map(this.renderNewsItem)} ) } renderNewsItem = (nws, idx) => (

{nws.title}

{nws.body}

); }