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/1/en/part1a.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ The easiest way to get started by far is by using a tool called
15
15
Let's create an application called <i>part1</i>, navigate to its directory and install the libraries:
16
16
17
17
```bash
18
-
npm create vite@latest part -- --template react
18
+
npm create vite@latest part1 -- --template react
19
19
cd part1
20
20
npm install
21
21
```
@@ -36,7 +36,7 @@ Open the browser and a text editor so that you can view the code as well as the
36
36
37
37

38
38
39
-
The code of the application resides in the <i>src</i> folder. Let's simplify the default code such that the contents of the file main.js looks like this:
39
+
The code of the application resides in the <i>src</i> folder. Let's simplify the default code such that the contents of the file main.jsx looks like this:
@@ -76,7 +76,7 @@ The course is currently (11 August 2023) being updated to use Vite. Some brands
76
76
77
77
### Component
78
78
79
-
The file <i>App.js</i> now defines a [React component](https://react.dev/learn/your-first-component) with the name <i>App</i>. The command on the final line of file <i>main.js</i>
79
+
The file <i>App.jsx</i> now defines a [React component](https://react.dev/learn/your-first-component) with the name <i>App</i>. The command on the final line of file <i>main.jsx</i>
@@ -252,7 +252,7 @@ but when writing JSX, the tag needs to be closed:
252
252
253
253
### Multiple components
254
254
255
-
Let's modify the file <i>App.js</i> as follows (NB: export at the bottom is left out in these <i>examples</i>, now and in the future. It is still needed for the code to work):
255
+
Let's modify the file <i>App.jsx</i> as follows (NB: export at the bottom is left out in these <i>examples</i>, now and in the future. It is still needed for the code to work):
256
256
257
257
```js
258
258
// highlight-start
@@ -626,7 +626,7 @@ For each web application for a series of exercises, it is recommended to submit
626
626
627
627
<i>The application that we will start working on in this exercise will be further developed in a few of the following exercises. In this and other upcoming exercise sets in this course, it is enough to only submit the final state of the application. If desired, you may also create a commit for each exercise of the series, but this is entirely optional.</i>
628
628
629
-
Use create-react-app to initialize a new application. Modify <i>main.js</i> to match the following
629
+
Use create-react-app to initialize a new application. Modify <i>main.jsx</i> to match the following
and remove extra files (App.css, App.test.js, index.css, logo.svg, setupTests.js, reportWebVitals.js)).
671
+
and remove extra files App.css and index.css, and the directory assets.
672
672
673
673
Unfortunately, the entire application is in the same component. Refactor the code so that it consists of three new components: <i>Header</i>, <i>Content</i>, and <i>Total</i>. All data still resides in the <i>App</i> component, which passes the necessary data to each component using <i>props</i>. <i>Header</i> takes care of rendering the name of the course, <i>Content</i> renders the parts and their number of exercises and <i>Total</i> renders the total number of exercises.
674
674
675
-
Define the new components in the file <i>App.js</i>.
675
+
Define the new components in the file <i>App.jsx</i>.
676
676
677
677
The <i>App</i> component's body will approximately be as follows:
So far all of our applications have been such that their appearance remains the same after the initial rendering. What if we wanted to create a counter where the value increased as a function of time or at the click of a button?
181
181
182
-
Let's start with the following. File <i>App.js</i> becomes:
182
+
Let's start with the following. File <i>App.jsx</i> becomes:
183
183
184
184
```js
185
185
constApp= (props) => {
@@ -192,7 +192,7 @@ const App = (props) => {
192
192
exportdefaultApp
193
193
```
194
194
195
-
And file <i>main.js</i> becomes:
195
+
And file <i>main.jsx</i> becomes:
196
196
197
197
```js
198
198
importReactDOMfrom'react-dom/client'
@@ -251,7 +251,7 @@ All of our components up till now have been simple in the sense that they have n
251
251
252
252
Next, let's add state to our application's <i>App</i> component with the help of React's [state hook](https://react.dev/learn/state-a-components-memory).
253
253
254
-
We will change the application as follows. <i>main.js</i> goes back to
254
+
We will change the application as follows. <i>main.jsx</i> goes back to
Copy file name to clipboardExpand all lines: src/content/1/en/part1d.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1163,7 +1163,7 @@ The application must display the total number of collected feedback for each cat
1163
1163
1164
1164
Note that your application needs to work only during a single browser session. Once you refresh the page, the collected feedback is allowed to disappear.
1165
1165
1166
-
It is advisable to use the same structure that is used in the material and previous exercise. File <i>main.js</i> is as follows:
1166
+
It is advisable to use the same structure that is used in the material and previous exercise. File <i>main.jsx</i> is as follows:
You can use the code below as a starting point for the <i>App.js</i> file:
1177
+
You can use the code below as a starting point for the <i>App.jsx</i> file:
1178
1178
1179
1179
```js
1180
1180
import { useState } from'react'
@@ -1310,7 +1310,7 @@ const App = () => {
1310
1310
exportdefaultApp
1311
1311
```
1312
1312
1313
-
Content of the file <i>main.js</i> is the same as in previous exercises.
1313
+
Content of the file <i>main.jsx</i> is the same as in previous exercises.
1314
1314
1315
1315
Find out how to generate random numbers in JavaScript, eg. via a search engine or on [Mozilla Developer Network](https://developer.mozilla.org). Remember that you can test generating random numbers e.g. straight in the console of your browser.
@@ -72,7 +72,7 @@ Kurssia ollaan tällä hetkellä (11.8.2023) päivittämässä käyttämään Vi
72
72
73
73
### Komponentti
74
74
75
-
Tiedosto <i>App.js</i> määrittelee nyt React-[komponentin](https://react.dev/learn/your-first-component) nimeltään <i>App</i>. Tiedoston <i>main.js</i> viimeisen rivin komento
75
+
Tiedosto <i>App.js</i> määrittelee nyt React-[komponentin](https://react.dev/learn/your-first-component) nimeltään <i>App</i>. Tiedoston <i>main.jsx</i> viimeisen rivin komento
@@ -248,7 +248,7 @@ mutta JSX:ää kirjoittaessa tagi on pakko sulkea:
248
248
249
249
### Monta komponenttia
250
250
251
-
Muutetaan tiedostoa <i>App.js</i> seuraavasti (muista, että alimman rivin export jätetään <i>esimerkeistä</i> nyt ja jatkossa pois, niiden on kuitenkin oltava koodissa jotta ohjelma toimisi):
251
+
Muutetaan tiedostoa <i>App.jsx</i> seuraavasti (muista, että alimman rivin export jätetään <i>esimerkeistä</i> nyt ja jatkossa pois, niiden on kuitenkin oltava koodissa jotta ohjelma toimisi):
252
252
253
253
```js
254
254
// highlight-start
@@ -624,7 +624,7 @@ code .
624
624
625
625
<i>Tässä tehtävässä aloitettavaa ohjelmaa kehitellään eteenpäin muutamassa seuraavassa tehtävässä. Tässä ja kurssin aikana muissakin vastaan tulevissa tehtäväsarjoissa ohjelman lopullisen version palauttaminen riittää. Voit toki halutessasi tehdä commitin jokaisen tehtävän jälkeisestä tilanteesta, mutta se ei ole välttämätöntä.</i>
626
626
627
-
Luo Vitellä uusi sovellus. Muuta <i>main.js</i> muotoon
627
+
Luo Vitellä uusi sovellus. Muuta <i>main.jsc</i> muotoon
@@ -670,7 +670,7 @@ ja poista ylimääräiset tiedostot <i>App.css</i> ja <i>index.css</i> ja hakemi
670
670
671
671
Koko sovellus on nyt ikävästi yhdessä komponentissa. Refaktoroi sovelluksen koodi siten, että se koostuu kolmesta uudesta komponentista: <i>Header</i>, <i>Content</i> ja <i>Total</i>. Kaikki data pidetään edelleen komponentissa <i>App</i>, joka välittää tarpeelliset tiedot kullekin komponentille <i>props:ien</i> avulla. <i>Header</i> huolehtii kurssin nimen renderöimisestä, <i>Content</i> osista ja niiden tehtävämääristä ja <i>Total</i> tehtävien yhteismäärästä.
672
672
673
-
Tee uudet komponentit tiedostoon <i>App.js</i>.
673
+
Tee uudet komponentit tiedostoon <i>App.jsx</i>.
674
674
675
675
Komponentin <i>App</i> runko tulee olemaan suunnilleen seuraavanlainen:
Toistaiseksi tekemämme sovellukset ovat olleet sellaisia, että kun niiden komponentit on kerran renderöity, niiden ulkoasua ei ole enää voinut muuttaa. Entä jos haluaisimme toteuttaa laskurin, jonka arvo kasvaa ajan kuluessa tai nappeja painettaessa?
@@ -250,7 +250,7 @@ Tähänastiset komponenttimme ovat olleet siinä mielessä yksinkertaisia, että
250
250
251
251
Määritellään nyt sovelluksemme komponentille <i>App</i> tila Reactin [state hookin](https://react.dev/learn/state-a-components-memory#meet-your-first-hook) avulla.
Muun sovelluksen voi tehdä tiedostoon <i>App.js</i>. Tiedoston sisältö voi olla aluksi seuraava:
1176
+
Muun sovelluksen voi tehdä tiedostoon <i>App.jsx</i>. Tiedoston sisältö voi olla aluksi seuraava:
1177
1177
1178
1178
```js
1179
1179
import { useState } from'react'
@@ -1307,7 +1307,7 @@ const App = () => {
1307
1307
exportdefaultApp
1308
1308
```
1309
1309
1310
-
Tiedoston <i>main.js</i> sisältö on sama kuin edellisissä tehtävissä.
1310
+
Tiedoston <i>main.jsx</i> sisältö on sama kuin edellisissä tehtävissä.
1311
1311
1312
1312
Google kertoo, miten voit generoida JavaScriptilla sopivia satunnaisia lukuja. Muista, että voit testata esim. satunnaislukujen generointia konsolissa.
Copy file name to clipboardExpand all lines: src/content/2/en/part2.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ lang: en
8
8
9
9
Let's continue our introduction to React. First, we will take a look at how to render a data collection, like a list of names, to the screen. After this, we will inspect how a user can submit data to a React application using HTML forms. Next, our focus shifts towards looking at how JavaScript code in the browser can fetch and handle data stored in a remote backend server. Lastly, we will take a quick look at a few simple ways of adding CSS styles to our React applications.
10
10
11
-
<i>Part updated 18th Jan 2023</i>
12
-
- <i>Exercise numbering changed, the old 2.11-13. moved to the end of the part</i>
0 commit comments