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
Copy file name to clipboardExpand all lines: src/content/learn/tutorial-tic-tac-toe.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1094,7 +1094,7 @@ function Square({ value, onSquareClick }) {
1094
1094
}
1095
1095
```
1096
1096
1097
-
Now you'll connect the `onSquareClick` prop to a function in the `Board`component that you'll name`handleClick`. To connect `onSquareClick`to`handleClick` you'll pass a function to the `onSquareClick` prop of the first `Square`component:
1097
+
Sada ćete povezati `onSquareClick` prop sa funkcijom u `Board`komponenti koju ćete nazvati`handleClick`. Da biste povezali `onSquareClick`sa`handleClick`, prosledićete funkciju kao vrednost `onSquareClick` prop-u prve `Square`komponente:
1098
1098
1099
1099
```js {7}
1100
1100
exportdefaultfunctionBoard() {
@@ -1109,7 +1109,7 @@ export default function Board() {
1109
1109
}
1110
1110
```
1111
1111
1112
-
Lastly, you will define the `handleClick`function inside the Board component to update the`squares`array holding your board's state:
1112
+
Na kraju, definisaćete funkciju `handleClick`unutar `Board` komponente kako biste update-ovali niz`squares`koji čuva state vaše table:
1113
1113
1114
1114
```js {4-8}
1115
1115
exportdefaultfunctionBoard() {
@@ -1127,17 +1127,17 @@ export default function Board() {
1127
1127
}
1128
1128
```
1129
1129
1130
-
The`handleClick`function creates a copy of the `squares`array (`nextSquares`) with the JavaScript `slice()`Array method. Then, `handleClick`updates the`nextSquares`array to add`X`to the first (`[0]` index) square.
1130
+
Funkcija`handleClick`kreira kopiju niza `squares` (`nextSquares`) korišćenjem JavaScript metode `slice()`za nizove. Zatim, `handleClick`ažurira niz`nextSquares`tako što dodaje`X`na prvi kvadrat (indeks `[0]`).
1131
1131
1132
-
Calling the`setSquares`function lets React know the state of the component has changed. This will trigger a re-render of the components that use the `squares`state (`Board`) as well as its child components (the `Square`components that make up the board).
1132
+
Pozivanjem funkcije`setSquares`obaveštavate React da se state komponente promenio. Ovo će pokrenuti ponovno renderovanje komponenti koje koriste state `squares` (`Board`), kao i njenih child komponenti (`Square`komponente koje čine tablu).
1133
1133
1134
1134
<Note>
1135
1135
1136
-
JavaScript supports [closures](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) which means an inner function (e.g.`handleClick`) has access to variables and functions defined in an outer function (e.g.`Board`). The`handleClick`function can read the`squares`state and call the `setSquares`method because they are both defined inside of the `Board` function.
1136
+
JavaScript podržava [closures](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures), što znači da unutrašnja funkcija (npr.`handleClick`) ima pristup varijablama i funkcijama definisanim u spoljašnjoj funkciji (npr.`Board`). Funkcija`handleClick`može da čita state`squares`i poziva metodu `setSquares`jer su obe definisane unutar funkcije `Board`.
1137
1137
1138
1138
</Note>
1139
1139
1140
-
Now you can add X's to the board... but only to the upper left square. Your `handleClick`function is hardcoded to update the index for the upper left square (`0`). Let's update `handleClick`to be able to update any square. Add an argument `i`to the `handleClick`function that takes the index of the square to update:
1140
+
Sada možete dodati X-ove na tablu... ali samo u gornji levi kvadrat. Vaša funkcija `handleClick`je trenutno hardkodirana da ažurira indeks gornjeg levog kvadrata (`0`). Hajde da ažuriramo `handleClick`tako da može ažurirati bilo koji kvadrat. Dodajte argument `i`funkciji `handleClick`koji prima indeks kvadrata koji treba ažurirati:
0 commit comments