Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created August 4, 2021 13:43
Show Gist options
  • Save hieptl/53a479d8b1b97ef608eb1d2833caca65 to your computer and use it in GitHub Desktop.
Save hieptl/53a479d8b1b97ef608eb1d2833caca65 to your computer and use it in GitHub Desktop.
Posts Component - Facebook Clone
// import useContext to get shared data.
import { useContext } from 'react';
// import Context.
import Context from '../Context';
// import custom components.
import Post from "./Post";
function Posts() {
const { wallPosts } = useContext(Context);
return (
<div>
{wallPosts.map((post) => (
<Post
key={post.id}
createdBy={post.createdBy}
message={post.message}
timestamp={post.timestamp}
imageUrl={post.imageUrl}
userAvatar={post.userAvatar}
/>
))}
</div>
);
}
export default Posts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment