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/part7a.md
+1-55Lines changed: 1 addition & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,60 +13,6 @@ In addition to the exercises in this and the next chapter, there are a series of
13
13
14
14
### React Router
15
15
16
-
This section has been moved to the [part 5](/en/part5/react_router_ui_frameworks). You still may do the below exercises.
17
-
18
-
</div>
19
-
20
-
<divclass="tasks">
21
-
22
-
### Exercises 7.1.-7.3.
23
-
24
-
Let's return to working with anecdotes. Use the redux-free anecdote app found in the repository <https://github.com/fullstack-hy2020/routed-anecdotes> as the starting point for the exercises.
25
-
26
-
If you clone the project into an existing git repository, remember to <i>delete the git configuration of the cloned application:</i>
27
-
28
-
```bash
29
-
cd routed-anecdotes // go first to directory of the cloned repository
30
-
rm -rf .git
31
-
```
32
-
33
-
The application starts the usual way, but first, you need to install its dependencies:
34
-
35
-
```bash
36
-
npm install
37
-
npm run dev
38
-
```
39
-
40
-
#### 7.1: Routed Anecdotes, step 1
41
-
42
-
Add React Router to the application so that by clicking links in the <i>Menu</i> component the view can be changed.
43
-
44
-
At the root of the application, meaning the path _/_, show the list of anecdotes:
45
-
46
-

47
-
48
-
The <i>Footer</i> component should always be visible at the bottom.
49
-
50
-
The creation of a new anecdote should happen e.g. in the path <i>create</i>:

59
-
60
-
Navigating to the page showing the single anecdote is done by clicking the name of that anecdote:
61
-
62
-

63
-
64
-
#### 7.3: Routed Anecdotes, step3
65
-
66
-
The default functionality of the creation form is quite confusing because nothing seems to be happening after creating a new anecdote using the form.
67
-
68
-
Improve the functionality such that after creating a new anecdote the application transitions automatically to showing the view for all anecdotes <i>and</i> the user is shown a notification informing them of this successful creation for the next five seconds:
69
-
70
-

16
+
This section has been moved to the [part 5](/en/part5/react_router_ui_frameworks).
Copy file name to clipboardExpand all lines: src/content/7/en/part7b.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -290,11 +290,11 @@ The internet is starting to fill up with more and more helpful material related
290
290
291
291
<divclass="tasks">
292
292
293
-
### Exercises 7.4.-7.8.
293
+
### Exercises 7.1.-7.5.
294
294
295
295
We'll continue with the app from the [exercises](/en/part7/react_router#exercises-7-1-7-3) of the [react router](/en/part7/react_router) chapter.
296
296
297
-
#### 7.4: Anecdotes and Hooks step 1
297
+
#### 7.1: Anecdotes and Hooks step 1
298
298
299
299
Simplify the anecdote creation form of your application with the _useField_ custom hook we defined earlier.
300
300
@@ -337,7 +337,7 @@ const App = () => {
337
337
}
338
338
```
339
339
340
-
#### 7.5: Anecdotes and Hooks step 2
340
+
#### 7.2: Anecdotes and Hooks step 2
341
341
342
342
Add a button to the form that you can use to clear all the input fields:
343
343
@@ -351,7 +351,7 @@ Depending on your solution, you may see the following warning in your console:
351
351
352
352
We will return to this warning in the next exercise.
353
353
354
-
#### 7.6: Anecdotes and Hooks step 3
354
+
#### 7.3: Anecdotes and Hooks step 3
355
355
356
356
If your solution did not cause a warning to appear in the console, you have already finished this exercise.
357
357
@@ -388,7 +388,7 @@ One simple fix would be to not use the spread syntax and write all of the forms
388
388
389
389
If we were to do this, we would lose much of the benefit provided by the <i>useField</i> hook. Instead, come up with a solution that fixes the issue, but is still easy to use with the spread syntax.
390
390
391
-
#### 7.7: Country hook
391
+
#### 7.4: Country hook
392
392
393
393
Let's return to exercises [2.18-2.20](/en/part2/adding_styles_to_react_app#exercises-2-18-2-20).
394
394
@@ -408,7 +408,7 @@ Use the API endpoint [name](https://studies.cs.helsinki.fi/restcountries/) to fe
408
408
409
409
Note that in this exercise it is essential to use useEffect's [second parameter](https://react.dev/reference/react/useEffect#parameters) array to control when the effect function is executed. See the course [part 2](/en/part2/adding_styles_to_react_app#couple-of-important-remarks) for more info how the second parameter could be used.
410
410
411
-
#### 7.8: Ultimate Hooks
411
+
#### 7.5: Ultimate Hooks
412
412
413
413
The code of the application responsible for communicating with the backend of the note application of the previous parts looks like this:
Copy file name to clipboardExpand all lines: src/content/7/en/part7f.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,9 +19,9 @@ One good piece of advice for both refactoring and writing new code is to take <i
19
19
20
20
<divclass="tasks">
21
21
22
-
### Exercises 7.9.-7.21.
22
+
### Exercises 7.6.-7.18.
23
23
24
-
#### 7.9: Automatic Code Formatting
24
+
#### 7.6: Automatic Code Formatting
25
25
26
26
In the previous parts, we used ESLint to ensure that the code follows the defined conventions. [Prettier](https://prettier.io/) is yet another approach for the same. According to the documentation, Prettier is <i>an opinionated code formatter</i>, that is, Prettier not only controls the code style but also formats the code according to the definition.
27
27
@@ -31,63 +31,63 @@ Take Prettier to use in your app and configure it to work with your editor.
31
31
32
32
### State Management: Zustand
33
33
34
-
<i>There are two alternative versions to choose for exercises 7.10-7.13: you can do the state management of the application either using Zustand or React Query and Context</i>. If you want to maximize your learning, you should do both versions!
34
+
<i>There are two alternative versions to choose for exercises 7.7-7.10: you can do the state management of the application either using Zustand or React Query and Context</i>. If you want to maximize your learning, you should do both versions!
35
35
36
36
Note: if you completed part 6 using Redux, you can of course use Redux instead of Zustand in this exercise series!
37
37
38
-
#### 7.10: Zustand, Step 1
38
+
#### 7.7: Zustand, Step 1
39
39
40
40
Refactor the application to use Zustand to manage the notification data.
41
41
42
-
#### 7.11: Zustand, Step 2
42
+
#### 7.8: Zustand, Step 2
43
43
44
44
<i>Note</i> that this and the next two exercises are quite laborious but incredibly educational.
45
45
46
46
Store the information about blog posts in the Zustand store. In this exercise, it is enough that you can see the blogs in the backend and create a new blog.
47
47
48
48
You are free to manage the state for logging in and creating new blog posts by using the internal state of React components.
49
49
50
-
#### 7.12: Zustand, Step 3
50
+
#### 7.9: Zustand, Step 3
51
51
52
52
Expand your solution so that it is again possible to like and delete a blog.
53
53
54
-
#### 7.13: Zustand, Step 4
54
+
#### 7.10: Zustand, Step 4
55
55
56
56
Store the information about the signed-in user in the Zustand store.
57
57
58
58
### State Management: React Query and Context
59
59
60
-
<i>There are two alternative versions to choose for exercises 7.10-7.13: you can do the state management of the application either using Zustand or React Query and Context</i>. If you want to maximize your learning, you should do both versions!
60
+
<i>There are two alternative versions to choose for exercises 7.7-7.10: you can do the state management of the application either using Zustand or React Query and Context</i>. If you want to maximize your learning, you should do both versions!
61
61
62
-
#### 7.10: React Query and Context step 1
62
+
#### 7.7: React Query and Context step 1
63
63
64
64
Refactor the app to use the useReducer-hook and context to manage the notification data.
65
65
66
-
#### 7.11: React Query and Context step 2
66
+
#### 7.8: React Query and Context step 2
67
67
68
68
Use React Query to manage the state for blog posts. For this exercise, it is sufficient that the application displays existing blogs and that the creation of a new blog is successful.
69
69
70
70
You are free to manage the state for logging in and creating new blog posts by using the internal state of React components.
71
71
72
-
#### 7.12: React Query and Context step 3
72
+
#### 7.9: React Query and Context step 3
73
73
74
74
Expand your solution so that it is again possible to like and delete a blog.
75
75
76
-
#### 7.13: React Query and Context step 4
76
+
#### 7.10: React Query and Context step 4
77
77
78
78
Use the useReducer-hook and context to manage the data for the logged in user.
79
79
80
80
### Views
81
81
82
82
The rest of the tasks are common to both the Zustand and React Query versions.
83
83
84
-
#### 7.14: Users view
84
+
#### 7.11: Users view
85
85
86
86
Implement a view to the application that displays all of the basic information related to users:
87
87
88
88

89
89
90
-
#### 7.15: Individual User View
90
+
#### 7.12: Individual User View
91
91
92
92
Implement a view for individual users that displays all of the blog posts added by that user:
93
93
@@ -122,7 +122,7 @@ const User = () => {
122
122
}
123
123
```
124
124
125
-
#### 7.16: Blog View
125
+
#### 7.13: Blog View
126
126
127
127
Implement a separate view for blog posts. You can model the layout of your view after the following example:
128
128
@@ -134,13 +134,13 @@ Users should be able to access this view by clicking the name of the blog post i
134
134
135
135
After you're done with this exercise, the functionality that was implemented in exercise 5.7 is no longer necessary. Clicking a blog post no longer needs to expand the item in the list and display the details of the blog post.
Copy file name to clipboardExpand all lines: src/content/7/fi/osa7a.md
+1-55Lines changed: 1 addition & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,60 +13,6 @@ Tämän ja seuraavan luvun tehtävien lisäksi seitsemäs osa sisältää kertaa
13
13
14
14
### React Router
15
15
16
-
Tämän luvun materiaali siirtynyt [osaan 5](/osa5/react_router_tyylikirjastot). Voit kuitenkin edelleen tehdä aiheeseen liittyvät tehtävät.
17
-
18
-
</div>
19
-
20
-
<divclass="tasks">
21
-
22
-
### Tehtävät 7.1.-7.3.
23
-
24
-
Jatketaan anekdoottien parissa. Ota seuraaviin tehtäviin pohjaksi repositoriossa <https://github.com/fullstack-hy2020/routed-anecdotes> oleva Reduxiton anekdoottisovellus.
25
-
26
-
Jos kloonaat projektin olemassaolevan Git-repositorion sisälle, <i>poista kloonatun sovelluksen Git-konfiguraatio</i>:
27
-
28
-
```bash
29
-
cd routed-anecdotes // eli mene ensin kloonatun repositorion hakemistoon
30
-
rm -rf .git
31
-
```
32
-
33
-
Sovellus käynnistyy normaaliin tapaan, mutta joudut ensin asentamaan sovelluksen riippuvuudet:
34
-
35
-
```bash
36
-
npm install
37
-
npm run dev
38
-
```
39
-
40
-
#### 7.1: routed anecdotes, step1
41
-
42
-
Lisää sovellukseen React Router siten, että <i>Menu</i>-komponentissa olevia linkkejä klikkailemalla saadaan säädeltyä näytettävää näkymää.
43
-
44
-
Sovelluksen juuressa eli polulla _/_ näytetään anekdoottien lista:
45
-
46
-

47
-
48
-
Pohjalla oleva <i>Footer</i>-komponentti tulee näyttää aina.
49
-
50
-
Uuden anekdootin luominen tapahtuu esim. polulla <i>create</i>:
51
-
52
-

53
-
54
-
#### 7.2: routed anecdotes, step2
55
-
56
-
Toteuta sovellukseen yksittäisen anekdootin tiedot näyttävä näkymä:
Luomislomakkeen oletusarvoinen toiminnallisuus on melko hämmentävä, sillä kun lomakkeen avulla luodaan uusi muistiinpano, mitään ei näytä tapahtuvan.
67
-
68
-
Paranna toiminnallisuutta siten, että luomisen jälkeen siirrytään automaattisesti kaikkien anekdoottien näkymään <i>ja</i> käyttäjälle näytetään viiden sekunnin ajan onnistuneesta lisäyksestä kertova notifikaatio:
69
-
70
-

16
+
Tämän luvun materiaali siirtynyt [osaan 5](/osa5/react_router_tyylikirjastot).
0 commit comments