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
+19-19
Original file line number
Diff line number
Diff line change
@@ -415,23 +415,23 @@ U ovom primeru, to je `MyApp`:
415
415
416
416
<DiagramGroup>
417
417
418
-
<Diagram name="sharing_data_parent" height={385} width={410} alt="Diagram showing a tree of three components, one parent labeled MyApp and two children labeled MyButton. MyApp contains a count value of zero which is passed down to both of the MyButton components, which also show value zero." >
418
+
<Diagram name="sharing_data_parent" height={385} width={410} alt="Dijagram prikazuje stablo od tri komponente, jedne parent oznake MyApp i dve children sa oznakom MyButton. MyApp sadrži vrednost brojača nula, koja se prosleđuje u obe MyButton komponente, koje takođe prikazuju vrednost nula." >
419
419
420
-
Initially, `MyApp`'s `count` state is`0`and is passed down to both children
420
+
Inicijalno, `MyApp` ima `count` state vrednosti`0`i prosleđuje se u obe children komponente
421
421
422
422
</Diagram>
423
423
424
-
<Diagram name="sharing_data_parent_clicked" height={385} width={410} alt="The same diagram as the previous, with the count of the parent MyApp component highlighted indicating a click with the value incremented to one. The flow to both of the children MyButton components is also highlighted, and the count value in each child is set to one indicating the value was passed down." >
424
+
<Diagram name="sharing_data_parent_clicked" height={385} width={410} alt="Isti dijagram kao prethodni, sa istaknutim brojačem parent MyApp komponente, koji ukazuje na klik sa vrednošću uvećanom na jedan. Protok do obe children MyButton komponente je takođe istaknut, a vrednost brojača u svakoj child komponenti je postavljena na jedan što ukazuje da je vrednost prosleđena." >
425
425
426
-
On click, `MyApp`updates its`count` state to`1`and passes it down to both children
426
+
Pri kliku, `MyApp`ažurira svoj`count` state na`1`i prosleđuje ga u obe children komponente
427
427
428
428
</Diagram>
429
429
430
430
</DiagramGroup>
431
431
432
-
Now when you click either button, the `count`in`MyApp`will change, which will change both of the counts in `MyButton`. Here's how you can express this in code.
432
+
Sada, kada kliknete na bilo koje dugme, `count`u`MyApp`će se promeniti, što će promeniti oba brojača u `MyButton`. Evo kako to možete izraziti u kodu.
433
433
434
-
First, *move the state up* from `MyButton`into`MyApp`:
434
+
Prvo, *pdignite state nagore* from `MyButton`u`MyApp`:
435
435
436
436
```js {2-6,18}
437
437
exportdefaultfunctionMyApp() {
@@ -443,20 +443,20 @@ export default function MyApp() {
443
443
444
444
return (
445
445
<div>
446
-
<h1>Counters that update separately</h1>
446
+
<h1>Brojači koji se ažuriraju odvojeno</h1>
447
447
<MyButton />
448
448
<MyButton />
449
449
</div>
450
450
);
451
451
}
452
452
453
453
functionMyButton() {
454
-
// ... we're moving code from here ...
454
+
// ... premestamo kod odavde ...
455
455
}
456
456
457
457
```
458
458
459
-
Then, *pass the state down* from`MyApp`to each`MyButton`, together with the shared click handler. You can pass information to `MyButton`using the JSX curly braces, just like you previously did with built-in tags like`<img>`:
459
+
Zatim, *prosleđujemo state nadole* iz`MyApp`u oba`MyButton`, zajedno sa zajedničkim handlerom za klik. Informacije možete proslediti u `MyButton`koristeći kovrdžaste zagrade u JSX-u, baš kao što ste to ranije radili sa ugrađenim tagovima poput`<img>`:
460
460
461
461
```js {11-12}
462
462
exportdefaultfunctionMyApp() {
@@ -468,29 +468,29 @@ export default function MyApp() {
468
468
469
469
return (
470
470
<div>
471
-
<h1>Counters that update together</h1>
471
+
<h1>Brojači koji se ažuriraju zajedno</h1>
472
472
<MyButton count={count} onClick={handleClick} />
473
473
<MyButton count={count} onClick={handleClick} />
474
474
</div>
475
475
);
476
476
}
477
477
```
478
478
479
-
The information you pass down like this is called _props_. Now the `MyApp`component contains the `count` state and the `handleClick` event handler, and *passes both of them down as props* to each of the buttons.
479
+
Informacije koje na ovaj način prosleđujete nazivaju se *props*. Sada `MyApp`komponenta sadrži `count` state i `handleClick` event handler, i *prosleđuje obe nadole kao props* svakom od dugmeta.
480
480
481
-
Finally, change`MyButton`to *read* the props you have passed from its parent component:
481
+
Konačno, promenite`MyButton`da *čita* props koje ste prosledili iz njegove parent komponente:
482
482
483
483
```js {1,3}
484
484
functionMyButton({ count, onClick }) {
485
485
return (
486
486
<button onClick={onClick}>
487
-
Clicked {count} times
487
+
Kliknuto {count} puta
488
488
</button>
489
489
);
490
490
}
491
491
```
492
492
493
-
When you click the button, the `onClick` handler fires. Each button's `onClick` prop was set to the `handleClick`function inside `MyApp`, so the code inside of it runs. That code calls`setCount(count +1)`, incrementing the `count` state variable. The new `count`value is passed as a prop to each button, so they all show the new value. This is called "lifting state up". By moving state up, you've shared it between components.
493
+
Kada kliknete na dugme, `onClick` handler se aktivira.`onClick` prop svakog dugmeta postavljen je na funkciju `handleClick`unutar `MyApp` pa se kod unutar nje izvršava. Taj kod poziva`setCount(count +1)`, inkrementira `count` state varijablu. Nova `count`vrednost se prosleđuje kao prop svakom dugmetu, pa svi prikazuju novu vrednost. Ovo se naziva "podizanje state-a nagore". Pomeranjema state-a nagore, podelili ste ga između komponenata.
494
494
495
495
<Sandpack>
496
496
@@ -506,7 +506,7 @@ export default function MyApp() {
506
506
507
507
return (
508
508
<div>
509
-
<h1>Counters that update together</h1>
509
+
<h1>Brojači koji se ažuriraju zajedno</h1>
510
510
<MyButton count={count} onClick={handleClick} />
511
511
<MyButton count={count} onClick={handleClick} />
512
512
</div>
@@ -516,7 +516,7 @@ export default function MyApp() {
516
516
functionMyButton({ count, onClick }) {
517
517
return (
518
518
<button onClick={onClick}>
519
-
Clicked {count} times
519
+
Kliknuto {count} puta
520
520
</button>
521
521
);
522
522
}
@@ -531,8 +531,8 @@ button {
531
531
532
532
</Sandpack>
533
533
534
-
## Next Steps {/*next-steps*/}
534
+
## Sledeći koraci {/*next-steps*/}
535
535
536
-
By now, you know the basics of how to write React code!
536
+
Sada već znate osnove pisanja React koda!
537
537
538
-
Check out the [Tutorial](/learn/tutorial-tic-tac-toe) to put them into practice and build your first mini-app with React.
538
+
Pogledajte [Tutorijal](/learn/tutorial-tic-tac-toe) biste primenili naučeno i izgradili svoj prvi mini-app sa React-om.
0 commit comments