Created
May 26, 2022 20:00
-
-
Save isaacbatst/9ac247cb62b2b6b1a63caadbc2b358ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// src/components/Posts.js | |
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
class Posts extends React.Component { | |
render(){ | |
const { posts } = this.props; | |
return ( | |
<ul> | |
{posts.map(({ id, title }) => <li key={id}>{title}</li>)} | |
</ul> | |
) | |
} | |
} | |
Posts.propTypes = { | |
posts: PropTypes.arrayOf(PropTypes.shape({ | |
id: PropTypes.string.isRequired, | |
title: PropTypes.string.isRequired, | |
})).isRequired, | |
}; | |
export default Posts; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment