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/2/en/part2e.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ If we wanted to target, let's say, each one of the notes with our styles, we cou
46
46
constNote= ({ note, toggleImportance }) => {
47
47
constlabel=note.important
48
48
?'make not important'
49
-
:'make important';
49
+
:'make important'
50
50
51
51
return (
52
52
<li>
@@ -83,7 +83,7 @@ In React we have to use the [className](https://react.dev/learn#adding-styles) a
83
83
constNote= ({ note, toggleImportance }) => {
84
84
constlabel=note.important
85
85
?'make not important'
86
-
:'make important';
86
+
:'make important'
87
87
88
88
return (
89
89
<li className='note'>// highlight-line
@@ -243,7 +243,7 @@ const Footer = () => {
243
243
return (
244
244
<div style={footerStyle}>
245
245
<br />
246
-
<em>Note app, Department of Computer Science, University of Helsinki 2024</em>
246
+
<em>Note app, Department of Computer Science, University of Helsinki 2025</em>
247
247
</div>
248
248
)
249
249
}
@@ -529,15 +529,15 @@ const App = () => {
529
529
530
530
The useEffect hook now has _[currency]_ as the second parameter. The effect function is therefore executed after the first render, and <i>always</i> after the table as its second parameter _[currency]_ changes. That is, when the state _currency_ gets a new value, the content of the table changes and the effect function is executed.
531
531
532
-
The effect has the following condition
532
+
It is natural to choose _null_ as the initial value for the variable _currency_, because _currency_ represents a single item. The initial value _null_ indicates that there is nothing in the state yet, and it is also easy to check with a simple if statement whether a value has been assigned to the variable. The effect has the following condition
533
533
534
534
```js
535
535
if (currency) {
536
536
// exchange rates are fetched
537
537
}
538
538
```
539
539
540
-
which prevents requesting the exchange rates just after the first render when the variable _currency_ still has the initial value, i.e. a null value.
540
+
which prevents requesting the exchange rates just after the first render when the variable _currency_ still has the initial value, i.e. a _null_ value.
541
541
542
542
So if the user writes e.g. <i>eur</i> in the search field, the application uses Axios to perform an HTTP GET request to the address <https://open.er-api.com/v6/latest/eur> and stores the response in the _rates_ state.
Copy file name to clipboardExpand all lines: src/content/2/fi/osa2e.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,7 +46,7 @@ Jos haluamme kohdistaa tyylejä esim. jokaiseen muistiinpanoon, voisimme käytt
46
46
constNote= ({ note, toggleImportance }) => {
47
47
constlabel=note.important
48
48
?'make not important'
49
-
:'make important';
49
+
:'make important'
50
50
51
51
return (
52
52
<li>
@@ -83,7 +83,7 @@ Reactissa tulee kuitenkin classin sijaan käyttää attribuuttia [className](htt
83
83
constNote= ({ note, toggleImportance }) => {
84
84
constlabel=note.important
85
85
?'make not important'
86
-
:'make important';
86
+
:'make important'
87
87
88
88
return (
89
89
<li className='note'>// highlight-line
@@ -242,7 +242,7 @@ const Footer = () => {
242
242
return (
243
243
<div style={footerStyle}>
244
244
<br />
245
-
<em>Note app, Department of Computer Science, University of Helsinki 2023</em>
245
+
<em>Note app, Department of Computer Science, University of Helsinki 2025</em>
246
246
</div>
247
247
)
248
248
}
@@ -524,15 +524,15 @@ const App = () => {
524
524
525
525
Efektifunktio siis suoritetaan ensimmäisen renderöinnin jälkeen, ja <i>aina</i> sen jälkeen kun sen toisena parametrina oleva taulukko eli esimerkin tapauksessa _[currency]_ muuttuu. Eli kun tila _currency_ saa uuden arvon, muuttuu taulukon sisältö ja efektifunktio suoritetaan.
526
526
527
-
Efektiin on tehty ehto
527
+
On luontevaa valita muuttujan _currency_ alkuarvoksi _null_, koska _currency_ kuvaa yksittäistä asiaa. Alkuarvo _null_ kertoo, että tilassa ei ole vielä mitään, ja tällöin on myös helppo tarkistaa yksinkertaisella if-lauseella, onko muuttujalle asetettu arvoa. Efektiin on tehty ehto
528
528
529
529
```js
530
530
if (currency) {
531
531
// haetaan valuuttakurssit
532
532
}
533
533
```
534
534
535
-
joka estää valuuttakurssien hakemisen ensimmäisen renderöininin yhteydessä, eli siinä vaiheessa kuin muuttujalla _currency_ on vasta alkuarvo eli _null_.
535
+
joka estää valuuttakurssien hakemisen ensimmäisen renderöinnin yhteydessä, eli siinä vaiheessa kun muuttujalla _currency_ on vasta alkuarvo _null_.
536
536
537
537
Jos käyttäjä siis kirjoittaa hakukenttään esim. <i>eur</i>, suorittaa sovellus Axiosin avulla HTTP GET ‑pyynnön osoitteeseen https://open.er-api.com/v6/latest/eur ja tallentaa vastauksen tilaan _rates_.
0 commit comments