Skip to content

Commit f0e4473

Browse files
committed
part2 vite
1 parent 36542d8 commit f0e4473

File tree

22 files changed

+170
-229
lines changed

22 files changed

+170
-229
lines changed

src/content/0/en/part0a.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,7 @@ Despite changes <i>all the submitted exercises remain valid</i>, and the course
340340
341341
Recent major changes
342342
343-
- Part 2 (18th Jan 2023): Exercise numbering changed, the old 2.11-13. moved to the end of the part
344-
- Part 6 (30th Jan 2023): A new section on React Query, useReducer and React context replaced the section on Redux connect
345-
- Part 8 (5th Feb 2023): Backend updated to use Apollo Server 4.0
346-
- Part 9 (12th Feb 2023): Content clarified, Patientor example app structure refactored to a much simpler form
343+
- Parts 1 and 2 (11-14th August): Create React app replaced with Vite
347344
348345
### Expanding on a previously completed course
349346

src/content/0/fi/osa0a.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,7 @@ Kurssilla ei ole enää vuosittaisia versiota. Kurssi on siis käynnissä koko a
282282
Muutoksista huolimatta <i>kaikki jo tehdyt palautukset säilyvät voimassa</i>, eli voit jatkaa kurssia päivityksistä huolimatta normaaliin tapaan.
283283

284284
Viimeaikaisia isompia muutoksia
285-
- Osa 2 (18.1.2023): Muutos tehtävien numeroinnissa, tehtävät 2.11-13. siirretty osan loppuun
286-
- Osa 6 (30.1.2023): Uusi luku aiheenaan React Query; useReducer ja React context korvasi Redux connect ‑luvun
287-
- Osa 8 (5.2.2023): Backend muutettu käyttämään Apollo Server ‑kirjaston versiota 4.0
288-
- Osa 9 (12.2.2023): Sisältöä tarkennettu, Patientor-esimerkkisovelluksen rakennetta yksinkertaistettu
285+
- Osat 1 ja 2 (11-14.8.2023): Create React app korvattu Vitellä
289286

290287
### Aiemmin suoritetun kurssin täydentäminen
291288

src/content/1/en/part1a.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The easiest way to get started by far is by using a tool called
1515
Let's create an application called <i>part1</i>, navigate to its directory and install the libraries:
1616

1717
```bash
18-
npm create vite@latest part -- --template react
18+
npm create vite@latest part1 -- --template react
1919
cd part1
2020
npm install
2121
```
@@ -36,7 +36,7 @@ Open the browser and a text editor so that you can view the code as well as the
3636

3737
![](../../images/1/1-vite4.png)
3838

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:
4040

4141
```js
4242
import ReactDOM from 'react-dom/client'
@@ -46,7 +46,7 @@ import App from './App'
4646
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
4747
```
4848

49-
and file <i>App.js</i> looks like this
49+
and file <i>App.jsx</i> looks like this
5050

5151
```js
5252
const App = () => {
@@ -76,7 +76,7 @@ The course is currently (11 August 2023) being updated to use Vite. Some brands
7676

7777
### Component
7878

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>
8080

8181
```js
8282
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
@@ -252,7 +252,7 @@ but when writing JSX, the tag needs to be closed:
252252

253253
### Multiple components
254254

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):
256256

257257
```js
258258
// highlight-start
@@ -626,7 +626,7 @@ For each web application for a series of exercises, it is recommended to submit
626626

627627
<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>
628628

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
630630

631631
```js
632632
import ReactDOM from 'react-dom/client'
@@ -636,7 +636,7 @@ import App from './App'
636636
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
637637
```
638638

639-
and <i>App.js</i> to match the following
639+
and <i>App.jsx</i> to match the following
640640

641641
```js
642642
const App = () => {
@@ -668,11 +668,11 @@ const App = () => {
668668
export default App
669669
```
670670

671-
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.
672672

673673
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.
674674

675-
Define the new components in the file <i>App.js</i>.
675+
Define the new components in the file <i>App.jsx</i>.
676676

677677
The <i>App</i> component's body will approximately be as follows:
678678

src/content/1/en/part1c.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const Hello = ({ name, age }) => {
179179
180180
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?
181181
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:
183183
184184
```js
185185
const App = (props) => {
@@ -192,7 +192,7 @@ const App = (props) => {
192192
export default App
193193
```
194194
195-
And file <i>main.js</i> becomes:
195+
And file <i>main.jsx</i> becomes:
196196
197197
```js
198198
import ReactDOM from 'react-dom/client'
@@ -251,7 +251,7 @@ All of our components up till now have been simple in the sense that they have n
251251
252252
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).
253253
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
255255
256256
```js
257257
import ReactDOM from 'react-dom/client'
@@ -261,7 +261,7 @@ import App from './App'
261261
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
262262
```
263263
264-
and <i>App.js</i> changes to the following:
264+
and <i>App.jsx</i> changes to the following:
265265
266266
```js
267267
import { useState } from 'react' // highlight-line

src/content/1/en/part1d.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ The application must display the total number of collected feedback for each cat
11631163

11641164
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.
11651165

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:
11671167

11681168
```js
11691169
import React from 'react'
@@ -1174,7 +1174,7 @@ import App from './App'
11741174
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
11751175
```
11761176

1177-
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:
11781178

11791179
```js
11801180
import { useState } from 'react'
@@ -1310,7 +1310,7 @@ const App = () => {
13101310
export default App
13111311
```
13121312

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.
13141314

13151315
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.
13161316

src/content/1/fi/osa1a.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Helpoin tapa päästä alkuun on [Vite](https://vitejs.dev/)-nimisen työkalun k
1414
Luodaan sovellus nimeltään <i>part1</i>, mennään sovelluksen sisältämään hakemistoon ja asennetaan sovelluksen käyttämät kirjastot:
1515

1616
```bash
17-
npm create vite@latest part -- --template react
17+
npm create vite@latest part1 -- --template react
1818
cd part1
1919
npm install
2020
```
@@ -35,7 +35,7 @@ Avataan selan sekä tekstieditori siten, että näet koodin ja web-sivun samaan
3535

3636
![](../../images/1/1-vite4.png)
3737

38-
Sovelluksen koodi on hakemistossa <i>src</i>. Yksinkertaistetaan valmiina olevaa koodia siten, että tiedoston <i>main.js</i> sisällöksi tulee:
38+
Sovelluksen koodi on hakemistossa <i>src</i>. Yksinkertaistetaan valmiina olevaa koodia siten, että tiedoston <i>main.jsx</i> sisällöksi tulee:
3939

4040
```js
4141
import ReactDOM from 'react-dom/client'
@@ -46,7 +46,7 @@ ReactDOM.createRoot(document.getElementById('root')).render(<App />)
4646

4747
```
4848

49-
ja tiedoston <i>App.js</i> sisällöksi
49+
ja tiedoston <i>App.jsx</i> sisällöksi
5050

5151
```js
5252
const App = () => (
@@ -72,7 +72,7 @@ Kurssia ollaan tällä hetkellä (11.8.2023) päivittämässä käyttämään Vi
7272

7373
### Komponentti
7474

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
7676

7777
```js
7878
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
@@ -248,7 +248,7 @@ mutta JSX:ää kirjoittaessa tagi on pakko sulkea:
248248

249249
### Monta komponenttia
250250

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):
252252

253253
```js
254254
// highlight-start
@@ -624,7 +624,7 @@ code .
624624

625625
<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>
626626

627-
Luo Vitellä uusi sovellus. Muuta <i>main.js</i> muotoon
627+
Luo Vitellä uusi sovellus. Muuta <i>main.jsc</i> muotoon
628628

629629
```js
630630
import ReactDOM from 'react-dom/client'
@@ -634,7 +634,7 @@ import App from './App'
634634
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
635635
```
636636

637-
ja tiedosto <i>App.js</i> muotoon
637+
ja tiedosto <i>App.jsx</i> muotoon
638638

639639
```js
640640
const App = () => {
@@ -670,7 +670,7 @@ ja poista ylimääräiset tiedostot <i>App.css</i> ja <i>index.css</i> ja hakemi
670670

671671
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ä.
672672

673-
Tee uudet komponentit tiedostoon <i>App.js</i>.
673+
Tee uudet komponentit tiedostoon <i>App.jsx</i>.
674674

675675
Komponentin <i>App</i> runko tulee olemaan suunnilleen seuraavanlainen:
676676

src/content/1/fi/osa1c.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ const Hello = ({ name, age }) => {
178178
179179
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?
180180
181-
Aloitetaan seuraavasta rungosta. Tiedostoon <i>App.js</i> tulee:
181+
Aloitetaan seuraavasta rungosta. Tiedostoon <i>App.jsx</i> tulee:
182182
183183
```js
184184
const App = (props) => {
@@ -191,7 +191,7 @@ const App = (props) => {
191191
export default App
192192
```
193193
194-
Tiedoston <i>main.js</i> sisältö on:
194+
Tiedoston <i>main.jsx</i> sisältö on:
195195
196196
```js
197197
import ReactDOM from 'react-dom/client'
@@ -250,7 +250,7 @@ Tähänastiset komponenttimme ovat olleet siinä mielessä yksinkertaisia, että
250250
251251
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.
252252
253-
Palautetaan <i>main.js</i> muotoon
253+
Palautetaan <i>main.jsx</i> muotoon
254254
255255
```js
256256
import ReactDOM from 'react-dom/client'
@@ -260,7 +260,7 @@ import App from './App'
260260
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
261261
```
262262
263-
ja muutetaan <i>App.js</i> muotoon:
263+
ja muutetaan <i>App.jsx</i> muotoon:
264264
265265
```js
266266
import { useState } from 'react' // highlight-line

src/content/1/fi/osa1d.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ Sovelluksen tulee näyttää jokaisen palautteen lukumäärä. Sovellus voi näy
11641164

11651165
Huomaa, että sovelluksen tarvitsee toimia vain yhden selaimen käyttökerran ajan. Esim. kun sivu refreshataan, tilastot saavat hävitä.
11661166

1167-
Kannattaa noudattaa samaa rakennetta kuin materiaalissa ja edellisessä tehtävässä, eli tiedoston <i>main.js</i> sisältö on seuraava:
1167+
Kannattaa noudattaa samaa rakennetta kuin materiaalissa ja edellisessä tehtävässä, eli tiedoston <i>main.jsx</i> sisältö on seuraava:
11681168

11691169
```js
11701170
import ReactDOM from 'react-dom/client'
@@ -1173,7 +1173,7 @@ import App from './App'
11731173
ReactDOM.createRoot(document.getElementById('root')).render(<App />)
11741174
```
11751175

1176-
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:
11771177

11781178
```js
11791179
import { useState } from 'react'
@@ -1307,7 +1307,7 @@ const App = () => {
13071307
export default App
13081308
```
13091309

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ä.
13111311

13121312
Google kertoo, miten voit generoida JavaScriptilla sopivia satunnaisia lukuja. Muista, että voit testata esim. satunnaislukujen generointia konsolissa.
13131313

src/content/2/en/part2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ lang: en
88

99
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.
1010

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>
11+
<i>Part updated 14th August 2023</i>
12+
- <i>Create React App replaced with Vite</i>
1313

1414
</div>

0 commit comments

Comments
 (0)