Created
April 4, 2020 14:35
-
-
Save goiblas/03a8664317958366b74202915e10c3f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Spinner } from '@wordpress/components'; | |
import { withSelect } from '@wordpress/data'; | |
const ArticlesList = ({ articles }) => { | |
if ( ! articles ) { | |
return ( | |
<p style={{textAlign: "center", padding: "1rem"}}> | |
<Spinner /> | |
</p> | |
); | |
} | |
return ( | |
<ul> | |
{ articles.map( (article, index) => ( | |
<li key={index}> | |
<a href={ article.link }> | |
{ article.title.rendered } | |
</a> | |
</li> | |
)) | |
} | |
</ul> | |
); | |
} | |
export default withSelect( (select, props) => { | |
return { | |
articles : select( 'core' ).getEntityRecords( 'postType', props.type, { per_page: 6 } ) | |
}} | |
)(ArticlesList) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment