From daaf8446b6364bbb78a6774fbfa58fa2cab3a2b2 Mon Sep 17 00:00:00 2001 From: Miro Rauhala <4082806+mirorauhala@users.noreply.github.com> Date: Wed, 30 Aug 2023 19:57:32 +0300 Subject: [PATCH 01/24] Translate Tic Tac Toe --- src/content/learn/tutorial-tic-tac-toe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/learn/tutorial-tic-tac-toe.md b/src/content/learn/tutorial-tic-tac-toe.md index 16e5f518d..e032de2af 100644 --- a/src/content/learn/tutorial-tic-tac-toe.md +++ b/src/content/learn/tutorial-tic-tac-toe.md @@ -1,5 +1,5 @@ --- -title: 'Tutorial: Tic-Tac-Toe' +title: 'Opas: Ristinolla' --- From 86800fd4c104d57323c833cf5a9c811dd77917f9 Mon Sep 17 00:00:00 2001 From: Miro Rauhala <4082806+mirorauhala@users.noreply.github.com> Date: Wed, 30 Aug 2023 20:14:08 +0300 Subject: [PATCH 02/24] Translate headings --- src/content/learn/tutorial-tic-tac-toe.md | 56 +++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/content/learn/tutorial-tic-tac-toe.md b/src/content/learn/tutorial-tic-tac-toe.md index e032de2af..757c7c306 100644 --- a/src/content/learn/tutorial-tic-tac-toe.md +++ b/src/content/learn/tutorial-tic-tac-toe.md @@ -4,24 +4,24 @@ title: 'Opas: Ristinolla' -You will build a small tic-tac-toe game during this tutorial. This tutorial does not assume any existing React knowledge. The techniques you'll learn in the tutorial are fundamental to building any React app, and fully understanding it will give you a deep understanding of React. +Tulet rakentamaan pienen ristinolla-pelin tässä oppaassa. Tämä opas ei oleta aikaisempaa React-osaamista. Tekniikat, joita opit oppaan aikana ovat perustavanlaatuisia mille tahansa React-sovellukselle ja niiden ymmärtäminen antaa sinulle syvällisen ymmärryksen Reactista. -This tutorial is designed for people who prefer to **learn by doing** and want to quickly try making something tangible. If you prefer learning each concept step by step, start with [Describing the UI.](/learn/describing-the-ui) +Tämä opas on tarkoitettu henkilöille, jotka suosivat **oppimaan tekemällä** ja haluavat nopeasti kokeilla tehdä jotain konkreettista. Jos suosit oppimista jokaisen käsitteen vaiheittain, aloita [Käyttöliittymän kuvaaminen](/learn/describing-the-ui) sivulta. -The tutorial is divided into several sections: +Tämä opas on jaettu useaan osaan: -- [Setup for the tutorial](#setup-for-the-tutorial) will give you **a starting point** to follow the tutorial. -- [Overview](#overview) will teach you **the fundamentals** of React: components, props, and state. -- [Completing the game](#completing-the-game) will teach you **the most common techniques** in React development. -- [Adding time travel](#adding-time-travel) will give you **a deeper insight** into the unique strengths of React. +- [Oppaan asennusvaihe](#setup-for-the-tutorial) antaa sinulle *lähtökohdan** oppaan seuraamiseen. +- [Yleiskatsaus](#overview) opettaa sinulle Reactin **perusteet**: komponentit, propsit, ja tilan. +- [Pelin viimeistely](#completing-the-game) opettaa sinulle **yleisimmät tekniikat** React kehityksessä. +- [Aikamatkustuksen lisääminen](#adding-time-travel) opettaa sinulle **syvällisen ymmärryksen** Reactin uniikkeihin vahvuuksiin. -### What are you building? {/*what-are-you-building*/} +### Mitä olet rakentamassa? {/*what-are-you-building*/} In this tutorial, you'll build an interactive tic-tac-toe game with React. @@ -200,7 +200,7 @@ We recommend that you check out the tic-tac-toe game above before continuing wit Once you've played around with the finished tic-tac-toe game, keep scrolling. You'll start with a simpler template in this tutorial. Our next step is to set you up so that you can start building the game. -## Setup for the tutorial {/*setup-for-the-tutorial*/} +## Oppaan asennusvaihe {/*setup-for-the-tutorial*/} In the live code editor below, click **Fork** in the top-right corner to open the editor in a new tab using the website CodeSandbox. CodeSandbox lets you write code in your browser and preview how your users will see the app you've created. The new tab should display an empty square and the starter code for this tutorial. @@ -273,11 +273,11 @@ If you get stuck, don't let this stop you! Follow along online instead and try a -## Overview {/*overview*/} +## Yleiskatsaus {/*overview*/} Now that you're set up, let's get an overview of React! -### Inspecting the starter code {/*inspecting-the-starter-code*/} +### Aloituskoodin tarkastelu {/*inspecting-the-starter-code*/} In CodeSandbox you'll see three main sections: @@ -346,7 +346,7 @@ Lines 1-5 brings all the necessary pieces together: The remainder of the file brings all the pieces together and injects the final product into `index.html` in the `public` folder. -### Building the board {/*building-the-board*/} +### Pelilaudan rakentaminen {/*building-the-board*/} Let's get back to `App.js`. This is where you'll spend the rest of the tutorial. @@ -508,7 +508,7 @@ Psssst... That's a lot to type! It's okay to copy and paste code from this page. -### Passing data through props {/*passing-data-through-props*/} +### Datan välittäminen propseilla {/*passing-data-through-props*/} Next, you'll want to change the value of a square from empty to "X" when the user clicks on the square. With how you've built the board so far you would need to copy-paste the code that updates the square nine times (once for each square you have)! Instead of copy-pasting, React's component architecture allows you to create a reusable component to avoid messy, duplicated code. @@ -702,7 +702,7 @@ body { -### Making an interactive component {/*making-an-interactive-component*/} +### Interaktiivisen komponentin luominen {/*making-an-interactive-component*/} Let's fill the `Square` component with an `X` when you click it. Declare a function called `handleClick` inside of the `Square`. Then, add `onClick` to the props of the button JSX element returned from the `Square`: @@ -897,7 +897,7 @@ body { -### React Developer Tools {/*react-developer-tools*/} +### React kehitystyökalut {/*react-developer-tools*/} React DevTools let you check the props and the state of your React components. You can find the React DevTools tab at the bottom of the _browser_ section in CodeSandbox: @@ -913,11 +913,11 @@ For local development, React DevTools is available as a [Chrome](https://chrome. -## Completing the game {/*completing-the-game*/} +## Pelin viimeistely {/*completing-the-game*/} By this point, you have all the basic building blocks for your tic-tac-toe game. To have a complete game, you now need to alternate placing "X"s and "O"s on the board, and you need a way to determine a winner. -### Lifting state up {/*lifting-state-up*/} +### Tilan nostaminen ylös {/*lifting-state-up*/} Currently, each `Square` component maintains a part of the game's state. To check for a winner in a tic-tac-toe game, the `Board` would need to somehow know the state of each of the 9 `Square` components. @@ -1333,7 +1333,7 @@ The DOM `` closes the JSX element to indicate that any following content shouldn't be placed inside the button. +Seuraava koodirivi palauttaa painonapin. `return` -JavaScript avainsanan tarkoittaa, mitä ikinä sen jälkeen tulee, palautetaan se arvo funktion kutsujalle. `` sulkee JSX elementin osoittaen, että mitään seuraavaa sisältöä ei tulisi sijoittaa painikkeen sisälle. #### `styles.css` {/*stylescss*/} -Click on the file labeled `styles.css` in the _Files_ section of CodeSandbox. This file defines the styles for your React app. The first two _CSS selectors_ (`*` and `body`) define the style of large parts of your app while the `.square` selector defines the style of any component where the `className` property is set to `square`. In your code, that would match the button from your Square component in the `App.js` file. +Paina tiedostosta nimeltään `styles.css` CodeSandboxin _Files_ osiossa. Tämä tiedosto määrittelee React sovelluksesi tyylin. Ensimmäiset kaksi _CSS selektoria_ (`*` ja `body`) määrittävät suuren osan sovelluksestasi tyyleistä, kun taas `.square` selektori määrittää minkä tahansa komponentin tyylin, jossa `className` ominaisuus on asetettu `square` arvoon. Koodissasi tämä vastaa painiketta `Square` komponentissa `App.js` tiedostossa. #### `index.js` {/*indexjs*/} -Click on the file labeled `index.js` in the _Files_ section of CodeSandbox. You won't be editing this file during the tutorial but it is the bridge between the component you created in the `App.js` file and the web browser. +Paina tiedostosta nimeltään `index.js` CodeSandboxin _Files_ osiossa. Et tule muokkaamaan tätä tiedostoa oppaan aikana, mutta se on silta `App.js` tiedostossa luomasi komponentin ja selaimen välillä. ```jsx import { StrictMode } from 'react'; @@ -339,14 +339,14 @@ import './styles.css'; import App from './App'; ``` -Lines 1-5 brings all the necessary pieces together: +Rivit 1-5 tuovat kaikki tarvittavat palaset yhteen: * React -* React's library to talk to web browsers (React DOM) -* the styles for your components -* the component you created in `App.js`. +* Reactin kirjasto, jolla se juttelee selaimen kanssa (React DOM) +* komponenttiesi tyylit +* luomasi komponentti `App.js` tiedostossa. -The remainder of the file brings all the pieces together and injects the final product into `index.html` in the `public` folder. +Loput tiedostosta tuo kaikki palaset yhteen ja palauttaa lopputuotteen `index.html` tiedostoon `public` hakemistossa. ### Pelilaudan rakentaminen {/*building-the-board*/} From ce1b7170fa56d4a8b33acdec9eb13f7dabff9fe2 Mon Sep 17 00:00:00 2001 From: Miro Rauhala <4082806+mirorauhala@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:25:41 +0300 Subject: [PATCH 07/24] Translate 'Building the Board' --- src/content/learn/tutorial-tic-tac-toe.md | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/content/learn/tutorial-tic-tac-toe.md b/src/content/learn/tutorial-tic-tac-toe.md index f6d7287d9..b38729895 100644 --- a/src/content/learn/tutorial-tic-tac-toe.md +++ b/src/content/learn/tutorial-tic-tac-toe.md @@ -350,9 +350,9 @@ Loput tiedostosta tuo kaikki palaset yhteen ja palauttaa lopputuotteen `index.ht ### Pelilaudan rakentaminen {/*building-the-board*/} -Let's get back to `App.js`. This is where you'll spend the rest of the tutorial. +Palataan takaisin `App.js` tiedostoon. Tämä on missä tulet viettämään lopun oppaan ajasta. -Currently the board is only a single square, but you need nine! If you just try and copy paste your square to make two squares like this: +Nykyisillään pelilauta on vain yksi neliö, mutta tarvitset yhdeksän! Voit yrittää vain kopioida ja liittää neliösi tehdäksesi kaksi neliötä näin: ```js {2} export default function Square() { @@ -360,7 +360,7 @@ export default function Square() { } ``` -You'll get this error: +Saat tämän virheen: @@ -368,7 +368,7 @@ You'll get this error: -React components need to return a single JSX element and not multiple adjacent JSX elements like two buttons. To fix this you can use *fragments* (`<>` and ``) to wrap multiple adjacent JSX elements like this: +React komponenttien täytyy palauttaa yksi JSX elementti, ei useampia vierekkäisiä JSX elementtejä kun kaksi painonappia. Korjataksesi tämän käytä *fragmenttejä* (`<>` ja ``) käärimään useampia vierekkäisiä JSX elementtejä näin: ```js {3-6} export default function Square() { @@ -381,17 +381,17 @@ export default function Square() { } ``` -Now you should see: +Nyt näet: -![two x-filled squares](../images/tutorial/two-x-filled-squares.png) +![kaksi x:llä täytettyä neliötä](../images/tutorial/two-x-filled-squares.png) -Great! Now you just need to copy-paste a few times to add nine squares and... +Hyvä! Nyt sinun tulee kopioida ja littää muutaman kerran saadaksesi yhdeksän neliötä ja sitten.... -![nine x-filled squares in a line](../images/tutorial/nine-x-filled-squares.png) +![yhdeksän x:llä täyettyä neliötä rivissä](../images/tutorial/nine-x-filled-squares.png) -Oh no! The squares are all in a single line, not in a grid like you need for our board. To fix this you'll need to group your squares into rows with `div`s and add some CSS classes. While you're at it, you'll give each square a number to make sure you know where each square is displayed. +Voi ei! Neliöt ovat kaikki yhdessä rivissä eikä ruudukossa kuten tarvitset sen pelilaudalla. Korjataksesi tämän sinun tulee ryhmitellä neliöt riveihin `div` elementeillä ja lisätä muutama CSS luokka. Samalla kun teet tämän, annat jokaiselle neliölle numeron varmistaaksesi, että tiedät missä jokainen neliö näytetään. -In the `App.js` file, update the `Square` component to look like this: +`App.js` tiedostossa, päivitä `Square` komponentti näyttämään tältä: ```js {3-19} export default function Square() { @@ -417,11 +417,11 @@ export default function Square() { } ``` -The CSS defined in `styles.css` styles the divs with the `className` of `board-row`. Now that you've grouped your components into rows with the styled `div`s you have your tic-tac-toe board: +`styles.css` tiedostossa määritelty CSS tyylittää divit `className`:n `board-row` arvolla. Nyt kun olet ryhmitellyt komponenttisi riveihin tyylitetyillä `div` elementeillä, sinulla on ristinolla-pelilauta: -![tic-tac-toe board filled with numbers 1 through 9](../images/tutorial/number-filled-board.png) +![ristinolla-pelilauta numeroitu yhdestä yhdeksään](../images/tutorial/number-filled-board.png) -But you now have a problem. Your component named `Square`, really isn't a square anymore. Let's fix that by changing the name to `Board`: +Mutta nyt sinulla on ongelma. Komponenttisi `Square` ei enää ole neliö. Korjataksesi tämän, muuta nimi `Square` komponentille `Board`:iksi: ```js {1} export default function Board() { @@ -429,7 +429,7 @@ export default function Board() { } ``` -At this point your code should look something like this: +Tässä kohtaa, koodisi tuli näyttää tämänkaltaiselta: @@ -506,7 +506,7 @@ body { -Psssst... That's a lot to type! It's okay to copy and paste code from this page. However, if you're up for a little challenge, we recommend only copying code that you've manually typed at least once yourself. +Pst... Tuossa on aika paljon kirjoitettavaa! On ihan ok kopioida ja liittää koodia tältä sivulta. Jos kuitenkin haluat haastetta, suosittelemme kopioida vain koodia, jonka olet kirjoittanut ainakin kerran itse. From aa7b7c6bc9ebd2641982381b6d198441f902d6fb Mon Sep 17 00:00:00 2001 From: Miro Rauhala <4082806+mirorauhala@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:36:51 +0300 Subject: [PATCH 08/24] Translate 'Passing data through props' --- src/content/learn/tutorial-tic-tac-toe.md | 38 +++++++++++------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/content/learn/tutorial-tic-tac-toe.md b/src/content/learn/tutorial-tic-tac-toe.md index b38729895..0e46b3f4c 100644 --- a/src/content/learn/tutorial-tic-tac-toe.md +++ b/src/content/learn/tutorial-tic-tac-toe.md @@ -512,9 +512,9 @@ Pst... Tuossa on aika paljon kirjoitettavaa! On ihan ok kopioida ja liittää ko ### Datan välittäminen propseilla {/*passing-data-through-props*/} -Next, you'll want to change the value of a square from empty to "X" when the user clicks on the square. With how you've built the board so far you would need to copy-paste the code that updates the square nine times (once for each square you have)! Instead of copy-pasting, React's component architecture allows you to create a reusable component to avoid messy, duplicated code. +Seuraavaksi haluat muuttaa neliön arvon tyhjästä X:ksi kun käyttäjä painaa neliötä. Tällä hetkellä sinun täytyisi kopioida ja liittää koodi, joka päivittää neliön yhdeksän kertaa (kerran jokaiselle neliölle)! Sen sijaan, että kopioisit ja liittäisit, Reactin komponenttiarkkitehtuuri antaa sinun luoda uudelleenkäytettävän komponentin välttääksesi sotkuisen, toistuvan koodin. -First, you are going to copy the line defining your first square (``) from your `Board` component into a new `Square` component: +Ensiksi, kopioit rivin, joka määrittelee ensimmäisen neliösi (``) `Board` komponentistasi uuteen `Square` komponenttiin: ```js {1-3} function Square() { @@ -526,7 +526,7 @@ export default function Board() { } ``` -Then you'll update the Board component to render that `Square` component using JSX syntax: +Sitten päivität `Board` komponentin renderöimään sen `Square` komponentin käyttäen JSX syntaksia: ```js {5-19} // ... @@ -553,15 +553,15 @@ export default function Board() { } ``` -Note how unlike the browser `div`s, your own components `Board` and `Square` must start with a capital letter. +Huomaa miten toisin kuin selainten `div`:it, omat komponenttisi `Board` ja `Square` täytyy alkaa isolla kirjaimella. -Let's take a look: +Katsotaanpa: -![one-filled board](../images/tutorial/board-filled-with-ones.png) +![pelilauta täytetty ykkösillä](../images/tutorial/board-filled-with-ones.png) -Oh no! You lost the numbered squares you had before. Now each square says "1". To fix this, you will use *props* to pass the value each square should have from the parent component (`Board`) to its child (`Square`). +Voi ei! Menetit numeroidut neliöt, jotka sinulla oli aiemmin. Nyt jokaisessa neliössä lukee "1". Korjataksesi tämän, käytä *propseja* välittääksesi arvon, jonka jokaisen neliön tulisi saada vanhemmalta komponentilta (`Board`) sen alakomponentille (`Square`). -Update the `Square` component to read the `value` prop that you'll pass from the `Board`: +Päivitä `Square` komponentti lukemaan `value` propsi, jonka välität `Board` komponentilta: ```js {1} function Square({ value }) { @@ -569,9 +569,9 @@ function Square({ value }) { } ``` -`function Square({ value })` indicates the Square component can be passed a prop called `value`. +`function Square({ value })` kertoo, että `Square` komponentille voidaan välittää `value` niminen propsi. -Now you want to display that `value` instead of `1` inside every square. Try doing it like this: +Nyt haluat näyttää `value` arvon `1`:n sijaan jokaisessa neliössä. Kokeile tehdä se näin: ```js {2} function Square({ value }) { @@ -579,11 +579,11 @@ function Square({ value }) { } ``` -Oops, this is not what you wanted: +Oho, tämä ei ollut mitä halusit: -![value-filled board](../images/tutorial/board-filled-with-value.png) +![pelilauta täytetty value tekstillä](../images/tutorial/board-filled-with-value.png) -You wanted to render the JavaScript variable called `value` from your component, not the word "value". To "escape into JavaScript" from JSX, you need curly braces. Add curly braces around `value` in JSX like so: +Halusit renderöidä JavaScript muuttujan nimeltään `value` komponentistasi, et sanan "value". Päästäksesi "takaisin JavaScriptiin" JSX:stä, tarvitset aaltosulkeet. Lisää aaltosulkeet `value`:n ympärille JSX:ssä näin: ```js {2} function Square({ value }) { @@ -591,11 +591,11 @@ function Square({ value }) { } ``` -For now, you should see an empty board: +Toistaiseksi, sinun tulisi nähdä tyhjä pelilauta: -![empty board](../images/tutorial/empty-board.png) +![tyhjä pelilauta](../images/tutorial/empty-board.png) -This is because the `Board` component hasn't passed the `value` prop to each `Square` component it renders yet. To fix it you'll add the `value` prop to each `Square` component rendered by the `Board` component: +Näin tapahtuu, koska `Board` komponentti ei ole välittänyt `value` propseja jokaiselle `Square` komponentille, jonka se renderöi. Korjataksesi tämän, lisää `value` propsi jokaiselle `Square` komponentille, jonka `Board` komponentti renderöi: ```js {5-7,10-12,15-17} export default function Board() { @@ -621,11 +621,11 @@ export default function Board() { } ``` -Now you should see a grid of numbers again: +Nyt sinun tulisi nähdä numeroitu ruudukko taas: -![tic-tac-toe board filled with numbers 1 through 9](../images/tutorial/number-filled-board.png) +![ristinolla-pelilauta täytetty yhdestä yhdeksään](../images/tutorial/number-filled-board.png) -Your updated code should look like this: +Päivitetyn koodisi tulisi näyttää tämänkaltaiselta: From 536c0d92d76d15199b5b506944ffb2456c93cd06 Mon Sep 17 00:00:00 2001 From: Miro Rauhala <4082806+mirorauhala@users.noreply.github.com> Date: Thu, 14 Sep 2023 20:00:00 +0300 Subject: [PATCH 09/24] Translate 'Making an interactive component' --- src/content/learn/tutorial-tic-tac-toe.md | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/content/learn/tutorial-tic-tac-toe.md b/src/content/learn/tutorial-tic-tac-toe.md index 0e46b3f4c..cc3e6be15 100644 --- a/src/content/learn/tutorial-tic-tac-toe.md +++ b/src/content/learn/tutorial-tic-tac-toe.md @@ -706,7 +706,7 @@ body { ### Interaktiivisen komponentin luominen {/*making-an-interactive-component*/} -Let's fill the `Square` component with an `X` when you click it. Declare a function called `handleClick` inside of the `Square`. Then, add `onClick` to the props of the button JSX element returned from the `Square`: +Täytetään `Square` komponentti `X`:llä kun klikkaat sitä. Määritä funktio nimeltään `handleClick` `Square` komponentin sisällä. Sitten, lisää `onClick` prosi painonapin JSX elementtiin, joka palautetaan `Square` komponentista: ```js {2-4,9} function Square({ value }) { @@ -725,19 +725,19 @@ function Square({ value }) { } ``` -If you click on a square now, you should see a log saying `"clicked!"` in the _Console_ tab at the bottom of the _Browser_ section in CodeSandbox. Clicking the square more than once will log `"clicked!"` again. Repeated console logs with the same message will not create more lines in the console. Instead, you will see an incrementing counter next to your first `"clicked!"` log. +Jos painat neliöstä nyt, sinun tulisi nähdä loki, jossa lukee `"clicked!"` _Console_ välilehdellä _Browser_ osiossa CodeSandboxissa. Painamalla neliötä useammin kuin kerran, lokiin tulee uusi rivi, jossa lukee `"clicked!"`. Toistuvat lokit samalla viestillä eivät luo uusia rivejä lokiin. Sen sijaan, näet kasvavan laskurin ensimmäisen `"clicked!"` lokin vieressä. -If you are following this tutorial using your local development environment, you need to open your browser's Console. For example, if you use the Chrome browser, you can view the Console with the keyboard shortcut **Shift + Ctrl + J** (on Windows/Linux) or **Option + ⌘ + J** (on macOS). +Jos seuraat tätä opasta paikallisessa kehitysympäristössä, sinun tulee avata selaimen konsoli. Esimerkiksi, jos käytät Chrome selainta, voit avata konsolin näppäinyhdistelmällä **Shift + Ctrl + J** (Windows/Linux) tai **Option + ⌘ + J** (macOS). -As a next step, you want the Square component to "remember" that it got clicked, and fill it with an "X" mark. To "remember" things, components use *state*. +Seuraavaksi, haluat Square komponentin "muistavat", että sitä painettiin, ja täyttää sen "X" merkillä. Komponentit käyttävät *tilaa* muistaakseen asioita. -React provides a special function called `useState` that you can call from your component to let it "remember" things. Let's store the current value of the `Square` in state, and change it when the `Square` is clicked. +React tarjoaa erityisen funktion nimeltään `useState`, jota voit kutsua komponentistasi, jotta se "muistaa" asioita. Tallennetaan `Square` komponentin nykyinen arvo tilaan ja muutetaan sitä, kun `Square` painetaan. -Import `useState` at the top of the file. Remove the `value` prop from the `Square` component. Instead, add a new line at the start of the `Square` that calls `useState`. Have it return a state variable called `value`: +Importtaa `useState` tiedoston ylläosassa. Poista `value` propsi `Square` komponentista. Sen sijaan, lisää uusi rivi `Square` komponentin alkuun, joka kutsuu `useState`:a. Anna sen palauttaa tilamuuttuja nimeltään `value`: ```js {1,3,4} import { useState } from 'react'; @@ -749,9 +749,9 @@ function Square() { //... ``` -`value` stores the value and `setValue` is a function that can be used to change the value. The `null` passed to `useState` is used as the initial value for this state variable, so `value` here starts off equal to `null`. +`value` pitää sisällään arvon ja `setValue` on funktio, jota voidaan käyttää muuttamaan arvoa. `null`, joka välitetään `useState`:lle, käytetään alkuperäisenä arvona tälle tilamuuttujalle, joten `value` on aluksi `null`. -Since the `Square` component no longer accepts props anymore, you'll remove the `value` prop from all nine of the Square components created by the Board component: +Koska `Square` komponentti ei enää hyväksy propseja, poistat `value` propin kaikista yhdeksästä `Square` komponentista, jotka `Board` komponentti luo: ```js {6-8,11-13,16-18} // ... @@ -778,7 +778,7 @@ export default function Board() { } ``` -Now you'll change `Square` to display an "X" when clicked. Replace the `console.log("clicked!");` event handler with `setValue('X');`. Now your `Square` component looks like this: +Nyt muutat `Square`:n näyttämään "X":n kun sitä painetaan. Korvaa `console.log("clicked!");` tapahtumankäsittelijä `setValue('X');`:lla. Nyt `Square` komponenttisi näyttää tältä: ```js {5} function Square() { @@ -799,13 +799,13 @@ function Square() { } ``` -By calling this `set` function from an `onClick` handler, you're telling React to re-render that `Square` whenever its `