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/index.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -285,40 +285,40 @@ Možete odgovarati na event-e deklarisanjem *event handler-a* funkcija za obradu
285
285
```js {2-4,7}
286
286
functionMyButton() {
287
287
functionhandleClick() {
288
-
alert('You clicked me!');
288
+
alert('Kliknuli ste me!');
289
289
}
290
290
291
291
return (
292
292
<button onClick={handleClick}>
293
-
Click me
293
+
Kliknite me
294
294
</button>
295
295
);
296
296
}
297
297
```
298
298
299
-
Notice how `onClick={handleClick}`has no parentheses at the end! Do not _call_ the event handler function: you only need to *pass it down*. React will call your event handler when the user clicks the button.
299
+
Obratite pažnju na to kako `onClick={handleClick}`nema zagrade na kraju! Ne treba da *pozivate* event handler funkciju: smo je treba *proslediti*. React će pozvati vaš event handler kada korisnik klikne na dugme.
300
300
301
-
## Updating the screen {/*updating-the-screen*/}
301
+
## Ažuriranje ekrana {/*updating-the-screen*/}
302
302
303
-
Often, you'll want your component to "remember" some information and display it. For example, maybe you want to count the number of times a button is clicked. To do this, add *state* to your component.
303
+
Često ćete želite da vaša komponenta "zapamti" neke informacije i prikaže ih. Na primer, možda želite da prebrojite koliko puta je dugme kliknuto. To do this, add *stanje (state)* u svoju komponentu.
304
304
305
-
First, import [`useState`](/reference/react/useState) from React:
305
+
Prvo, uvezite [`useState`](/reference/react/useState) iz React-a:
306
306
307
307
```js
308
308
import { useState } from'react';
309
309
```
310
310
311
-
Now you can declare a *state variable* inside your component:
311
+
Sada možete deklarisati *state varijablu* unutar vaše komponente:
312
312
313
313
```js
314
314
functionMyButton() {
315
315
const [count, setCount] =useState(0);
316
316
// ...
317
317
```
318
318
319
-
You’ll get two things from `useState`: the current state (`count`), and the function that lets you update it (`setCount`). You can give them any names, but the convention is to write `[something, setSomething]`.
319
+
Od`useState` dobićete dobiti dve stvari: trenutni state (`count`), i funkciju koja vam omogućava da ga ažurirate (`setCount`). Možete im dati bilo koja imena, ali je konvencija da pišete `[nešto, setNešto]`.
320
320
321
-
The first time the button is displayed, `count`will be`0`because you passed `0`to `useState()`. When you want to change state, call`setCount()`and pass the new value to it. Clicking this button will increment the counter:
321
+
Prvi put kada se dugme prikaže, `count`će biti`0`jer ste `0`prosledili u `useState()`. Kada želite da promenite state, pozovite`setCount()`i prosledite joj novu vrednost. Klikom na ovo dugme inkrementujte brojač:
322
322
323
323
```js {5}
324
324
functionMyButton() {
@@ -330,15 +330,15 @@ function MyButton() {
330
330
331
331
return (
332
332
<button onClick={handleClick}>
333
-
Clicked {count} times
333
+
Kliknuto je {count} puta
334
334
</button>
335
335
);
336
336
}
337
337
```
338
338
339
-
React will call your component function again. This time, `count`will be`1`. Then it will be `2`. And so on.
339
+
React će ponovo pozvati funkciju vaše komponente. Ovaj put, `count`će biti`1`. Zatim će biti `2`. I tako dalje.
340
340
341
-
If you render the same component multiple times, each will get its own state. Click each button separately:
341
+
Ako renderujete istu komponentu više puta, svaka će dobiti svoje sopstveni state. Kliknite svako dugme posebno:
342
342
343
343
<Sandpack>
344
344
@@ -348,7 +348,7 @@ import { useState } from 'react';
348
348
exportdefaultfunctionMyApp() {
349
349
return (
350
350
<div>
351
-
<h1>Counters that update separately</h1>
351
+
<h1>Brojači koji se ažuriraju nezavisno</h1>
352
352
<MyButton />
353
353
<MyButton />
354
354
</div>
@@ -364,7 +364,7 @@ function MyButton() {
364
364
365
365
return (
366
366
<button onClick={handleClick}>
367
-
Clicked {count} times
367
+
Kliknuto je {count} puta
368
368
</button>
369
369
);
370
370
}
@@ -379,7 +379,7 @@ button {
379
379
380
380
</Sandpack>
381
381
382
-
Notice how each button "remembers" its own `count`state and doesn't affect other buttons.
382
+
Primetite kako svako dugme "pamti" svoj sopstveni state brojača `count`i ne utiče na drugu dugmad.
0 commit comments