|
1 | 1 | import React from 'react';
|
2 |
| -import './App.css'; |
3 | 2 | import reactLogo from './Assets/react-logo.png';
|
4 | 3 | import PostList from './Components/PostList';
|
5 | 4 | import PostProvider, {PostContext} from './Contexts/PostProvider';
|
6 | 5 | import UserSelectDropdown from './Components/UserSelectDropdown';
|
7 | 6 | import PostListItem from './Components/PostListItem';
|
8 | 7 | import Spinner from './Components/Spinner';
|
9 | 8 |
|
10 |
| -function App() { |
11 |
| - return ( |
12 |
| - <div className="container"> |
13 |
| - <div className="row mt-5"> |
14 |
| - <div className="col-12 d-flex justify-content-center"> |
15 |
| - <img src={reactLogo} alt="React Logo" style={{ width: '200px' }} /> |
16 |
| - </div> |
17 |
| - <div className="col-12"> |
18 |
| - <PostProvider> |
19 |
| - <PostContext.Consumer> |
20 |
| - {({ isLoading, posts, getPostsForUserWithId, deletePostWithId }) => ( |
21 |
| - <> |
22 |
| - <UserSelectDropdown handleChange={userId => getPostsForUserWithId(userId)} /> |
23 |
| - {isLoading ? <Spinner /> : ( |
24 |
| - <PostList> |
25 |
| - {posts.map(post => ( |
26 |
| - <PostListItem |
27 |
| - {...post} |
28 |
| - handleDeleteClicked={deletePostWithId} |
29 |
| - /> |
30 |
| - ))} |
31 |
| - </PostList> |
32 |
| - )} |
33 |
| - </> |
34 |
| - )} |
35 |
| - </PostContext.Consumer> |
36 |
| - </PostProvider> |
37 |
| - </div> |
| 9 | +const App = () => ( |
| 10 | + <div className="container"> |
| 11 | + <div className="row mt-5"> |
| 12 | + <div className="col-12 d-flex justify-content-center"> |
| 13 | + <img src={reactLogo} alt="React Logo" style={{ width: '200px' }} /> |
| 14 | + </div> |
| 15 | + <div className="col-12"> |
| 16 | + <PostProvider> |
| 17 | + <PostContext.Consumer> |
| 18 | + {({ isLoading, posts, getPostsForUserWithId, deletePostWithId }) => ( |
| 19 | + <> |
| 20 | + <UserSelectDropdown handleChange={userId => getPostsForUserWithId(userId)} /> |
| 21 | + {isLoading ? <Spinner /> : ( |
| 22 | + <PostList> |
| 23 | + {posts.map(post => ( |
| 24 | + <PostListItem |
| 25 | + {...post} |
| 26 | + handleDeleteClicked={deletePostWithId} |
| 27 | + /> |
| 28 | + ))} |
| 29 | + </PostList> |
| 30 | + )} |
| 31 | + </> |
| 32 | + )} |
| 33 | + </PostContext.Consumer> |
| 34 | + </PostProvider> |
38 | 35 | </div>
|
39 | 36 | </div>
|
40 |
| - ); |
41 |
| -} |
| 37 | + </div> |
| 38 | +); |
42 | 39 |
|
43 | 40 | export default App;
|
0 commit comments