Skip to content

Instantly share code, notes, and snippets.

@Davidegloh
Last active June 19, 2021 10:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Davidegloh/8b714f53ce7bb5acd856ec109548873d to your computer and use it in GitHub Desktop.
Save Davidegloh/8b714f53ce7bb5acd856ec109548873d to your computer and use it in GitHub Desktop.
[map-2]#map2
const Posts = ({posts }) => (
<main className="posts">
<h1 className="posts-title">{post.title}</h1>
<div className="posts-list">
{posts.map((post) => (
<Post
//on utilise l'id de la clé
key={post.id}
//déversement du props
{...post}
/>
))}
</div>
</main>
);
Posts.propTypes ={
posts:PropTypes.arrayOf(
PropTypes.shape({ // à cause de l'id de la clé
id: PropTypes.number.isRequired, // à cause de l'id de la clé
}),
),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment