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
In the tic-tac-toe game's history, each past move has a unique ID associated with it: it's the sequential number of the move. Moves will never be re-ordered, deleted, or inserted in the middle, so it's safe to use the move index as a key.
2293
+
Ristinolla-pelin historiassa, jokaisella aikaisemmalla siirrolla on uniikki ID: se on siirron järjestysnumero. Siirtoja ei koskaan järjestetä uudelleen, poisteta tai lisätä keskelle, joten on turvallista käyttää siirron indeksiä avaimena.
2294
2294
2295
-
In the `Game`function, you can add the key as `<li key={move}>`, and if you reload the rendered game, React's "key" error should disappear:
2295
+
`Game`funktiossa, voit lisätä avaimen `<li key={move}>`, ja jos lataat pelin uudelleen, Reactin "key" virheen tulisi kadota:
2296
2296
2297
2297
```js {4}
2298
2298
constmoves=history.map((squares, move) => {
@@ -2484,7 +2484,7 @@ export default function Game() {
2484
2484
}
2485
2485
```
2486
2486
2487
-
Next, update the `jumpTo`function inside `Game` to update that `currentMove`. You'll also set `xIsNext`to`true` if the number that you're changing `currentMove` to is even.
2487
+
Seuraavaksi, päivitä `jumpTo`funktio `Game`:n sisällä päivittämään `currentMove`. Asetat myös `xIsNext`arvoon`true`, jos numero, jota olet muuttamassa `currentMove`:ksi on parillinen.
2488
2488
2489
2489
```js {4-5}
2490
2490
exportdefaultfunctionGame() {
@@ -2497,10 +2497,10 @@ export default function Game() {
2497
2497
}
2498
2498
```
2499
2499
2500
-
You will now make two changes to the `Game`'s `handlePlay`function which is called when you click on a square.
2500
+
Teet nyt kaksi muutosta `Game` komponentin `handlePlay`funktioon, joka kutsutaan kun klikkaat ruutua.
2501
2501
2502
-
- If you "go back in time" and then make a new move from that point, you only want to keep the history up to that point. Instead of adding `nextSquares`after all items (`...` spread syntax) in`history`, you'll add it after all items in `history.slice(0, currentMove +1)`so that you're only keeping that portion of the old history.
2503
-
- Each time a move is made, you need to update `currentMove`to point to the latest history entry.
2502
+
- Jos "palaat ajassa taaksepäin" ja teet uuden siirron siitä pisteestä, haluat pitää historian vain siihen pisteeseen asti. Sen sijaan, että lisäisit `nextSquares`kaikkien kohteiden (`...` spread-syntaksi) jälkeen`history`:ssa, lisäät sen kaikkien kohteiden jälkeen `history.slice(0, currentMove +1)`jotta pidät vain sen osan vanhasta historiasta.
2503
+
- Joka kerta kun siirto tehdään, sinun täytyy päivittää `currentMove`osoittamaan viimeisimpään historiaan.
2504
2504
2505
2505
```js {2-4}
2506
2506
functionhandlePlay(nextSquares) {
@@ -2511,7 +2511,7 @@ function handlePlay(nextSquares) {
2511
2511
}
2512
2512
```
2513
2513
2514
-
Finally, you will modify the `Game`component to render the currently selected move, instead of always rendering the final move:
2514
+
Lopuksi, muutat `Game`komponenttia renderöimään valitun siirron, sen sijaan että renderöisit aina viimeisimmän siirron:
2515
2515
2516
2516
```js {5}
2517
2517
exportdefaultfunctionGame() {
@@ -2524,7 +2524,7 @@ export default function Game() {
2524
2524
}
2525
2525
```
2526
2526
2527
-
If you click on any step in the game's history, the tic-tac-toe board should immediately update to show what the board looked like after that step occurred.
2527
+
Jos klikkaat mitä tahansa siirtoa pelin historiassa, ristinolla-pelin taulukko tulisi päivittyä näyttämään miltä taulukko näytti sen siirron jälkeen.
0 commit comments