You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/7/en/part7d.md
+34-16Lines changed: 34 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ lang: en
7
7
8
8
<divclass="content">
9
9
10
-
In addition to the six exercises in the [React Hooks](/en/part7/more_about_react_hooks) sections of this part of the course material, 16 exercises continue our work on the BlogList application that we worked on in parts four and five of the course material. Some of the following exercises are "features" that are independent of one another, meaning that there is no need to finish them in any particular order. You are free to skip over a part of the exercises if you wish to do so. Quite many of them are about applying the advanced state management technique (Zustand, React Query and context) covered in [part 6](/en/part6).
10
+
In addition to the six exercises in the [React Hooks](/en/part7/more_about_react_hooks) sections of this part of the course material, 13 exercises continue our work on the BlogList application that we worked on in parts four and five of the course material. Some of the following exercises are "features" that are independent of one another, meaning that there is no need to finish them in any particular order. You are free to skip over a part of the exercises if you wish to do so. Quite many of them are about applying the advanced state management technique (Zustand, React Query and context) covered in [part 6](/en/part6).
11
11
12
12
If you do not want to use your BlogList application, you are free to use the code from the model solution as a starting point for these exercises.
13
13
@@ -21,7 +21,7 @@ One good piece of advice for both refactoring and writing new code is to take <i
21
21
22
22
<divclass="tasks">
23
23
24
-
### Exercises 7.7.-7.22.
24
+
### Exercises 7.7.-7.19.
25
25
26
26
These exercises assume that you have already completed the exercises [5.24-5.29](/en/part5/react_router_ui_frameworks#exercises-5-24-5-29). If you have not, do those first.
27
27
@@ -124,19 +124,45 @@ Expand your solution so that it is again possible to like and delete a blog.
124
124
125
125
#### 7.14: React Query and Context step 4
126
126
127
-
Use the useReducer-hook and context to manage the data for the logged in user.
127
+
Use the Context API to manage the data for the logged in user.
128
128
129
-
### Views
129
+
### Cleanup
130
+
131
+
#### 7.15: Custom hooks
132
+
133
+
Your application most likely contains code that handles the logged-in user via <i>localStorage</i> in several places:
Extract this logic into a custom hook called <i>usePersistentUser</i>. The hook should read the initial value from <i>localStorage</i> on mount and keep the stored value in sync whenever it is updated or cleared. It should be usable like this:
Also take the [useField](/en/part7/more_about_react_hooks) hook introduced earlier in this part into use in the forms.
154
+
155
+
### More views
130
156
131
157
The rest of the tasks are common to both the Zustand and React Query versions.
132
158
133
-
#### 7.15: Users view
159
+
#### 7.16: Users view
134
160
135
161
Implement a view to the application that displays all of the basic information related to users:
136
162
137
163

138
164
139
-
#### 7.16: Individual User View
165
+
#### 7.17: Individual User View
140
166
141
167
Implement a view for individual users that displays all of the blog posts added by that user:
142
168
@@ -171,7 +197,7 @@ const User = () => {
171
197
}
172
198
```
173
199
174
-
#### 7.19: Comments, step 1
200
+
#### 7.18: Comments, step 1
175
201
176
202
Implement the functionality for commenting the blog posts:
177
203
@@ -183,20 +209,12 @@ In this exercise, it is enough for the frontend to only display the comments tha
183
209
184
210
An appropriate mechanism for adding comments to a blog post would be an HTTP POST request to the <i>api/blogs/:id/comments</i> endpoint.
185
211
186
-
#### 7.20: Comments, step 2
212
+
#### 7.19: Comments, step 2
187
213
188
214
Extend your application so that users can add comments to blog posts from the frontend:
189
215
190
216

191
217
192
-
#### 7.21: Styles, step 1
193
-
194
-
Improve the appearance of your application by applying one of the methods shown in the course material.
195
-
196
-
#### 7.22: Styles, step 2
197
-
198
-
You can mark this exercise as finished if you use an hour or more for styling your application.
199
-
200
218
This was the last exercise for this part of the course and it's time to push your code to GitHub and mark all of your finished exercises to the [exercise submission system](https://studies.cs.helsinki.fi/stats/courses/fullstackopen).
0 commit comments