Skip to content

Commit 84146af

Browse files
committed
- refactor
1 parent 2d2f415 commit 84146af

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/App.jsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@ import { PostList } from './components/PostList';
88
const postsWithUsers = postsFromServer.map(post => ({
99
...post,
1010
user: usersFromServer.find(user => user.id === post.userId),
11-
}));
12-
13-
const postsWithComments = postsWithUsers.map(post => ({
14-
...post,
1511
comments: commentsFromServer.filter(comment => comment.postId === post.id),
1612
}));
1713

1814
export const App = () => (
1915
<section className="App">
2016
<h1 className="App__title">Static list of posts</h1>
21-
<PostList posts={postsWithComments} />
17+
<PostList posts={postsWithUsers} />
2218
</section>
2319
);

src/components/PostInfo/PostInfo.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const PostInfo = ({ post }) => (
77
<h3 className="PostInfo__title">{post.title}</h3>
88
<p>
99
{' Posted by '}
10-
<UserInfo user={post.user} />
10+
{post.user && <UserInfo user={post.user} />}
1111
</p>
1212
</div>
1313
<p className="PostInfo__body">{post.body}</p>

0 commit comments

Comments
 (0)