Skip to content

Commit 1216787

Browse files
committed
Translate 'Implementing time travel'
1 parent 9743626 commit 1216787

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/content/learn/tutorial-tic-tac-toe.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,9 +2290,9 @@ Avainten ei tarvitse olla globaalisti uniikkeja. Riittää, että ne ovat uniikk
22902290
22912291
### Aikamatkustuksen toteutus {/*implementing-time-travel*/}
22922292
2293-
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.
22942294
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:
22962296
22972297
```js {4}
22982298
const moves = history.map((squares, move) => {
@@ -2484,7 +2484,7 @@ export default function Game() {
24842484
}
24852485
```
24862486
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.
24882488
24892489
```js {4-5}
24902490
export default function Game() {
@@ -2497,10 +2497,10 @@ export default function Game() {
24972497
}
24982498
```
24992499
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.
25012501
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.
25042504
25052505
```js {2-4}
25062506
function handlePlay(nextSquares) {
@@ -2511,7 +2511,7 @@ function handlePlay(nextSquares) {
25112511
}
25122512
```
25132513
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:
25152515
25162516
```js {5}
25172517
export default function Game() {
@@ -2524,7 +2524,7 @@ export default function Game() {
25242524
}
25252525
```
25262526
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.
25282528
25292529
<Sandpack>
25302530

0 commit comments

Comments
 (0)