Skip to content

Instantly share code, notes, and snippets.

@isaacbatst
Created May 26, 2022 20:00
Show Gist options
  • Save isaacbatst/9ac247cb62b2b6b1a63caadbc2b358ef to your computer and use it in GitHub Desktop.
Save isaacbatst/9ac247cb62b2b6b1a63caadbc2b358ef to your computer and use it in GitHub Desktop.
// 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