Last active
June 19, 2021 10:22
-
-
Save Davidegloh/8b714f53ce7bb5acd856ec109548873d to your computer and use it in GitHub Desktop.
[map-2]#map2
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
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