Skip to content

Commit 559f71f

Browse files
committed
Update part 2e
1 parent 07d5073 commit 559f71f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/content/2/en/part2e.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If we wanted to target, let's say, each one of the notes with our styles, we cou
4646
const Note = ({ note, toggleImportance }) => {
4747
const label = note.important
4848
? 'make not important'
49-
: 'make important';
49+
: 'make important'
5050

5151
return (
5252
<li>
@@ -83,7 +83,7 @@ In React we have to use the [className](https://react.dev/learn#adding-styles) a
8383
const Note = ({ note, toggleImportance }) => {
8484
const label = note.important
8585
? 'make not important'
86-
: 'make important';
86+
: 'make important'
8787

8888
return (
8989
<li className='note'> // highlight-line
@@ -243,7 +243,7 @@ const Footer = () => {
243243
return (
244244
<div style={footerStyle}>
245245
<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>
247247
</div>
248248
)
249249
}
@@ -529,15 +529,15 @@ const App = () => {
529529
530530
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.
531531
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
533533
534534
```js
535535
if (currency) {
536536
// exchange rates are fetched
537537
}
538538
```
539539
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.
541541
542542
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.
543543

src/content/2/fi/osa2e.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Jos haluamme kohdistaa tyylejä esim. jokaiseen muistiinpanoon, voisimme käytt
4646
const Note = ({ note, toggleImportance }) => {
4747
const label = note.important
4848
? 'make not important'
49-
: 'make important';
49+
: 'make important'
5050

5151
return (
5252
<li>
@@ -83,7 +83,7 @@ Reactissa tulee kuitenkin classin sijaan käyttää attribuuttia [className](htt
8383
const Note = ({ note, toggleImportance }) => {
8484
const label = note.important
8585
? 'make not important'
86-
: 'make important';
86+
: 'make important'
8787

8888
return (
8989
<li className='note'> // highlight-line
@@ -242,7 +242,7 @@ const Footer = () => {
242242
return (
243243
<div style={footerStyle}>
244244
<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>
246246
</div>
247247
)
248248
}
@@ -524,15 +524,15 @@ const App = () => {
524524
525525
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.
526526
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
528528
529529
```js
530530
if (currency) {
531531
// haetaan valuuttakurssit
532532
}
533533
```
534534
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_.
536536
537537
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_.
538538

0 commit comments

Comments
 (0)