Skip to content

Commit cec3550

Browse files
committed
nexttick
1 parent 6c17ceb commit cec3550

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ function Board({ xIsNext, squares, onPlay }) {
5757
const winner = calculateWinner(squares);
5858
let status;
5959
if (winner) {
60-
status = 'Winner: ' + winner;
60+
status = 'Pobednik: ' + winner;
6161
} else {
62-
status = 'Next player: ' + (xIsNext ? 'X' : 'O');
62+
status = 'Sledeći igrač : ' + (xIsNext ? 'X' : 'O');
6363
}
6464

6565
return (
@@ -103,9 +103,9 @@ export default function Game() {
103103
const moves = history.map((squares, move) => {
104104
let description;
105105
if (move > 0) {
106-
description = 'Go to move #' + move;
106+
description = 'Prebacite se na potez #' + move;
107107
} else {
108-
description = 'Go to game start';
108+
description = 'Prebacite se na početak';
109109
}
110110
return (
111111
<li key={move}>
@@ -917,17 +917,17 @@ Za rad u lokalnom okruženju, React DevTools je dostupan kao ekstenzija za [Chro
917917
918918
Do ovog trenutka, imate sve osnovne građevinske blokove za vašu iks-oks igru. Da biste je kompletirali, potrebno da naizmenično postavljate "X" i "O" na tablu, i potreban vam je način da odredite pobednika.
919919
920-
### Lifting state up {/*lifting-state-up*/}
920+
### Podizanje state-a {/*lifting-state-up*/}
921921
922-
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.
922+
Trenutno svaka `Square` komponenta čuva deo state-a igre. Da bi se proverilo ko je pobednik u igri iks-oks, `Board` bi morao nekako da zna state svake od 9 `Square` komponenti.
923923
924-
How would you approach that? At first, you might guess that the `Board` needs to "ask" each `Square` for that `Square`'s state. Although this approach is technically possible in React, we discourage it because the code becomes difficult to understand, susceptible to bugs, and hard to refactor. Instead, the best approach is to store the game's state in the parent `Board` component instead of in each `Square`. The `Board` component can tell each `Square` what to display by passing a prop, like you did when you passed a number to each Square.
924+
Kako biste to rešili? Možda biste pomislili da `Board` treba da „pita” svaku `Square` komponentu za njen state. Iako je ovaj pristup tehnički moguć u React-u, ne preporučujemo ga jer kod postaje težak za razumevanje, podložan je greškama i teško ga je refaktorisati. Umesto toga, najbolji pristup je da se state igre čuva u parent komponenti `Board`, umesto u svakoj `Square` komponenti. Komponenta `Board` može da kaže svakoj `Square` komponenti šta treba da prikaže prosleđivanjem props-a, kao što ste ranije prosleđivali broj svakoj `Square` komponenti.
925925
926-
**To collect data from multiple children, or to have two child components communicate with each other, declare the shared state in their parent component instead. The parent component can pass that state back down to the children via props. This keeps the child components in sync with each other and with their parent.**
926+
**Da biste sakupili podatke od više child komponenti ili omogućili komunikaciju između dve child komponente, definišite zajednički state u njihovoj parent komponenti. Parent komponenta može da prosledi taj state nazad child komponentama putem props-a. Na ovaj način child komponente ostaju sinhronizovane međusobno i sa parent komponentom.**
927927
928-
Lifting state into a parent component is common when React components are refactored.
928+
Podizanje state-a u parent komponentu je uobičajena praksa pri refaktorisanju React komponenti.
929929
930-
Let's take this opportunity to try it out. Edit the `Board` component so that it declares a state variable named `squares` that defaults to an array of 9 nulls corresponding to the 9 squares:
930+
Hajde da iskoristimo ovu priliku i isprobamo ovo. Izmenite komponentu `Board` tako da deklariše varijablu state-a pod nazivom `squares`, koja ima podrazumevanu vrednost u vidu niza od 9 `null` vrednosti koje odgovaraju za svaki od 9 kvadrata:
931931
932932
```js {3}
933933
// ...
@@ -939,13 +939,13 @@ export default function Board() {
939939
}
940940
```
941941
942-
`Array(9).fill(null)` creates an array with nine elements and sets each of them to `null`. The `useState()` call around it declares a `squares` state variable that's initially set to that array. Each entry in the array corresponds to the value of a square. When you fill the board in later, the `squares` array will look like this:
942+
`Array(9).fill(null)` kreira niz sa devet elemenata i postavlja svaki od njih na `null`. Poziv `useState()` oko njega deklariše varijablu state-a pod nazivom `squares`, koja je inicijalno postavljena za taj niz. Svaki element u nizu odgovara vrednosti jednog kvadrata. Kada kasnije popunite tablu, niz `squares` će izgledati ovako:
943943
944944
```jsx
945945
['O', null, 'X', 'X', 'X', 'O', 'O', null, null]
946946
```
947947
948-
Now your `Board` component needs to pass the `value` prop down to each `Square` that it renders:
948+
Sada vaša `Board` komponenta treba da prosledi `value` prop svakoj `Square` komponenti koju renderuje:
949949
950950
```js {6-8,11-13,16-18}
951951
export default function Board() {
@@ -972,19 +972,19 @@ export default function Board() {
972972
}
973973
```
974974
975-
Next, you'll edit the `Square` component to receive the `value` prop from the Board component. This will require removing the Square component's own stateful tracking of `value` and the button's `onClick` prop:
975+
Zatim ćete izmeniti `Square` komponentu da prima `value` prop iz `Board` komponente. Ovo će zahtevati uklanjanje sopstvenog state-a `value` iz `Square` komponente, kao i `onClick` props-a dugmeta:
976976
977977
```js {1,2}
978978
function Square({value}) {
979979
return <button className="square">{value}</button>;
980980
}
981981
```
982982
983-
At this point you should see an empty tic-tac-toe board:
983+
U ovom trenutku trebalo bi da vidite praznu tablu za igru iks-oks:
984984
985-
![empty board](../images/tutorial/empty-board.png)
985+
![prazna tabla](../images/tutorial/empty-board.png)
986986
987-
And your code should look like this:
987+
A vaš kod bi trebalo da izgleda ovako:
988988
989989
<Sandpack>
990990
@@ -1066,11 +1066,11 @@ body {
10661066
10671067
</Sandpack>
10681068
1069-
Each Square will now receive a `value` prop that will either be `'X'`, `'O'`, or `null` for empty squares.
1069+
Svaka `Square` komponenta će sada primati `value` prop koji može imati vrednost `'X'`, `'O'` ili `null` za prazne kvadrate.
10701070
1071-
Next, you need to change what happens when a `Square` is clicked. The `Board` component now maintains which squares are filled. You'll need to create a way for the `Square` to update the `Board`'s state. Since state is private to a component that defines it, you cannot update the `Board`'s state directly from `Square`.
1071+
Sledeće, treba da promenite šta se dešava kada se klikne na `Square`. `Board` komponenta sada vodi računa o tome koji su kvadrati popunjeni. Biće vam potrebno da napravite način na koji `Square` može da update-uje state komponente `Board`. Pošto je state privatan za komponentu koja ga definiše, ne možete update-ovati state komponente `Board` direktno iz `Square`.
10721072
1073-
Instead, you'll pass down a function from the `Board` component to the `Square` component, and you'll have `Square` call that function when a square is clicked. You'll start with the function that the `Square` component will call when it is clicked. You'll call that function `onSquareClick`:
1073+
Umesto toga, prosledićete funkciju iz `Board` komponente u `Square` komponentu, i `Square` će pozvati tu funkciju kada se na nju klikne. Počećete sa funkcijom koju će `Square` komponenta pozvati kada se klikne na nju. Tu funkciju ćete nazvati `onSquareClick`:
10741074
10751075
```js {3}
10761076
function Square({ value }) {
@@ -1082,7 +1082,7 @@ function Square({ value }) {
10821082
}
10831083
```
10841084
1085-
Next, you'll add the `onSquareClick` function to the `Square` component's props:
1085+
Zatim, dodaćete funkciju `onSquareClick` u props `Square` komponente:
10861086
10871087
```js {1}
10881088
function Square({ value, onSquareClick }) {

0 commit comments

Comments
 (0)