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/describing-the-ui.md
+71-69Lines changed: 71 additions & 69 deletions
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,29 @@
1
1
---
2
-
title: Describing the UI
2
+
title: Opisivanje korisničkog interfejsa (UI)
3
3
---
4
4
5
5
<Intro>
6
6
7
-
React is a JavaScript library for rendering user interfaces (UI). UI is built from small units like buttons, text, and images. React lets you combine them into reusable, nestable *components.*From web sites to phone apps, everything on the screen can be broken down into components. In this chapter, you'll learn to create, customize, and conditionally display React components.
7
+
React je JavaScript biblioteka za prikazivanje korisničkog interfejsa (UI). UI se sastoji od malih jedinica kao što su dugmad, tekst i slike. React vam omogućava da ih kombinujete u ponovljive, nested (ugnježdene) *komponente.*Od veb sajtova do telefonskih aplikacija, sve na ekranu može se razbiti na komponente. U ovoj glavi naučićete kako da kreirate, prilagodite i uslovno prikažete React komponente.
8
8
9
9
</Intro>
10
10
11
11
<YouWillLearnisChapter={true}>
12
12
13
-
*[How to write your first React component](/learn/your-first-component)
14
-
*[When and how to create multi-component files](/learn/importing-and-exporting-components)
15
-
*[How to add markup to JavaScript with JSX](/learn/writing-markup-with-jsx)
16
-
*[How to use curly braces with JSX to access JavaScript functionality from your components](/learn/javascript-in-jsx-with-curly-braces)
17
-
*[How to configure components with props](/learn/passing-props-to-a-component)
18
-
*[How to conditionally render components](/learn/conditional-rendering)
19
-
*[How to render multiple components at a time](/learn/rendering-lists)
20
-
*[How to avoid confusing bugs by keeping components pure](/learn/keeping-components-pure)
13
+
*[Kako da napišete svoju prvu React komponentu](/learn/your-first-component)
14
+
*[Kada i kako da kreirate više komponenti u jednom fajlu](/learn/importing-and-exporting-components)
15
+
*[Kako da dodate markup u JavaScript pomoću JSX](/learn/writing-markup-with-jsx)
16
+
*[Kako da koristite vitičaste zagrade u JSX-u da biste pristupili funkcionalnosti JavaScript-a iz vaših komponenti](/learn/javascript-in-jsx-with-curly-braces)
17
+
*[Kako da konfigurišete komponente sa props](/learn/passing-props-to-a-component)
18
+
*[Kako da uslovno prikažete komponente](/learn/conditional-rendering)
19
+
*[Kako da prikažete više komponenti odjednom](/learn/rendering-lists)
20
+
*[Kako da izbegnete zbunjujuće greške tako što ćete komponente držati čistim](/learn/keeping-components-pure)
21
21
22
22
</YouWillLearn>
23
23
24
-
## Your first component {/*your-first-component*/}
24
+
## Vaša prva komponenta {/*your-first-component*/}
25
25
26
-
React applications are built from isolated pieces of UI called *components*. A React component is a JavaScript function that you can sprinkle with markup. Components can be as small as a button, or as large as an entire page. Here is a `Gallery`component rendering three `Profile`components:
26
+
React aplikacije su izgrađene of izoliranih delova korisničkog interfejsa (UI) koje se zovu *komponente*. React komponenta je Javascript funkcija koju možete začiniti markup-om. Komponente mogu biti male kao dugme ili velike kao cela stranica. Ovde je `Gallery`komponenta koja prikazuje tri `Profile`komponente:
Read**[Your First Component](/learn/your-first-component)**to learn how to declare and use React components.
60
+
Pročitajte**[Vaša prva komponenta](/learn/your-first-component)**da biste naučili kako da deklarišete i koristite React komponente.
61
61
62
62
</LearnMore>
63
63
64
-
## Importing and exporting components {/*importing-and-exporting-components*/}
64
+
## Importovanje i exportovanje komponenti {/*importing-and-exporting-components*/}
65
65
66
-
You can declare many components in one file, but large files can get difficult to navigate. To solve this, you can *export* a component into its own file, and then *import* that component from another file:
66
+
Možete deklarisati mnogo komponenti u jednom fajlu, ali veliki fajlovi mogu postati teški za navigaciju. Da biste to rešili, možete *exportovati* komponentu u svoj fajl, a zatim *importovati* tu komponentu iz drugog fajla:
67
67
68
68
69
69
<Sandpack>
@@ -84,7 +84,7 @@ import Profile from './Profile.js';
Read**[Importing and Exporting Components](/learn/importing-and-exporting-components)**to learn how to split components into their own files.
115
+
Pročitajte**[Importovanje i exportovanje komponenti](/learn/importing-and-exporting-components)**da biste naučili kako da podelite komponente u svoje fajlove.
116
116
117
117
</LearnMore>
118
118
119
-
## Writing markup with JSX {/*writing-markup-with-jsx*/}
119
+
## Pisanje markup-a sa JSX {/*writing-markup-with-jsx*/}
120
120
121
-
Each React component is a JavaScript function that may contain some markup that React renders into the browser. React components use a syntax extension called JSX to represent that markup. JSX looks a lot like HTML, but it is a bit stricter and can display dynamic information.
121
+
Svaka React komponenta je JavaScript funkcija koja može sadržati neki markup koji React prikazuje u browser-u. React komponente koriste sintaksu proširenja zvanu JSX da predstave taj markup. JSX izgleda mnogo kao HTML, ali je malo stroži i može prikazati dinamičke informacije.
122
122
123
-
If we paste existing HTML markup into a React component, it won't always work:
123
+
Ako kopirate postojeći HTML markup u React komponentu, neće uvek raditi:
124
124
125
125
<Sandpack>
126
126
127
127
```js
128
128
exportdefaultfunctionTodoList() {
129
129
return (
130
130
// This doesn't quite work!
131
-
<h1>Hedy Lamarr's Todos</h1>
131
+
<h1>Hedy Lamarr's Todo lista</h1>
132
132
<img
133
133
src="https://i.imgur.com/yXOvdOSs.jpg"
134
134
alt="Hedy Lamarr"
135
135
class="photo"
136
136
>
137
137
<ul>
138
-
<li>Invent new traffic lights
139
-
<li>Rehearse a movie scene
140
-
<li>Improve spectrum technology
138
+
<li>Izmisli nove semafore
139
+
<li>Vežbaj scenu iz filma
140
+
<li>Unapredi tehnologiju spektra
141
141
</ul>
142
142
);
143
143
}
@@ -149,7 +149,7 @@ img { height: 90px; }
149
149
150
150
</Sandpack>
151
151
152
-
If you have existing HTML like this, you can fix it using a [converter](https://transform.tools/html-to-jsx):
152
+
Ako imate postojeći HTML kao što je ovaj, možete ga popraviti pomoću [konvertera](https://transform.tools/html-to-jsx):
153
153
154
154
<Sandpack>
155
155
@@ -164,9 +164,9 @@ export default function TodoList() {
164
164
className="photo"
165
165
/>
166
166
<ul>
167
-
<li>Invent newtraffic lights</li>
168
-
<li>Rehearse a movie scene</li>
169
-
<li>Improve spectrum technology</li>
167
+
<li>Izmisli nove semafore</li>
168
+
<li>Vežbaj scenu iz filma</li>
169
+
<li>Unapredi tehnologiju spektra</li>
170
170
</ul>
171
171
</>
172
172
);
@@ -181,13 +181,13 @@ img { height: 90px; }
181
181
182
182
<LearnMorepath="/learn/writing-markup-with-jsx">
183
183
184
-
Read**[Writing Markup with JSX](/learn/writing-markup-with-jsx)**to learn how to write valid JSX.
184
+
Pročitajte**[Pisanje markup-a sa JSX](/learn/writing-markup-with-jsx)**da biste naučili kako da napišete validan JSX.
185
185
186
186
</LearnMore>
187
187
188
-
## JavaScript in JSX with curly braces {/*javascript-in-jsx-with-curly-braces*/}
188
+
## JavaScript u JSX-u sa vitičastim zagradama {/*javascript-in-jsx-with-curly-braces*/}
189
189
190
-
JSX lets you write HTML-like markup inside a JavaScript file, keeping rendering logic and content in the same place. Sometimes you will want to add a little JavaScript logic or reference a dynamic property inside that markup. In this situation, you can use curly braces in your JSX to "open a window" to JavaScript:
190
+
JSX vam dozvoljava da pišete HTML sličan markup unutar JavaScript fajla, čuvajući logiku prikazivanja i sadržaja na istom mestu. Ponekad ćete želeti da dodate malo JavaScript logike ili da referencirate dinamičko svojstvo unutar tog markup-a. U ovoj situaciji možete koristiti vitičaste zagrade u vašem JSX-u da "otvorite prozor" ka JavaScript-u:
191
191
192
192
<Sandpack>
193
193
@@ -210,9 +210,9 @@ export default function TodoList() {
210
210
alt="Gregorio Y. Zara"
211
211
/>
212
212
<ul>
213
-
<li>Improve the videophone</li>
214
-
<li>Prepare aeronautics lectures</li>
215
-
<li>Work on the alcohol-fuelled engine</li>
213
+
<li>Unapredi the videophone</li>
214
+
<li>Pripremi predavanja iz aeronautike</li>
215
+
<li>Radi na motoru koji radi na alkohol</li>
216
216
</ul>
217
217
</div>
218
218
);
@@ -229,13 +229,13 @@ body > div > div { padding: 20px; }
Read **[JavaScript in JSX with Curly Braces](/learn/javascript-in-jsx-with-curly-braces)** to learn how to access JavaScript data from JSX.
232
+
Pročitajte **[JavaScript u JSX-u sa vitičastim zagradama](/learn/javascript-in-jsx-with-curly-braces)** da biste naučili kako da pristupite JavaScript podacima iz JSX-a.
233
233
234
234
</LearnMore>
235
235
236
-
## Passing props to a component {/*passing-props-to-a-component*/}
React components use *props* to communicate with each other. Every parent component can pass some information to its child components by giving them props. Props might remind you of HTML attributes, but you can pass any JavaScript value through them, including objects, arrays, functions, and even JSX!
238
+
React komponente koriste *props* da bi komunicirale jedna sa drugom. Svaki roditeljski(parent) komponent može proslediti neke informacije svojoj deci(children) pomoću props-a. Props vam mogu podsetiti na HTML atribute, ali možete proslediti bilo koju JavaScript vrednost kroz njih, uključujući objekte, nizove, funkcije i čak JSX!
Your components will often need to display different things depending on different conditions. In React, you can conditionally render JSX using JavaScript syntax like `if`statements, `&&`, and`? :`operators.
319
+
Vaše komponente će često morati da prikažu različite stvari u zavisnosti od različitih uslova. U React-u, možete uslovno prikazati JSX koristeći JavaScript sintaksu kao što su `if`naredbe, `&&` i`? :`operatori.
320
320
321
-
In this example, the JavaScript `&&` operator is used to conditionally render a checkmark:
321
+
U ovom primeru, JavaScript `&&` operator se koristi da bi se uslovno prikazala kvačica:
322
322
323
323
<Sandpack>
324
324
@@ -334,19 +334,19 @@ function Item({ name, isPacked }) {
334
334
exportdefaultfunctionPackingList() {
335
335
return (
336
336
<section>
337
-
<h1>Sally Ride's Packing List</h1>
337
+
<h1>Sally Ride lista za pakovanje</h1>
338
338
<ul>
339
339
<Item
340
340
isPacked={true}
341
-
name="Space suit"
341
+
name="Svemirsko odelo"
342
342
/>
343
343
<Item
344
344
isPacked={true}
345
-
name="Helmet with a golden leaf"
345
+
name="Kaciga sa zlatnim listom"
346
346
/>
347
347
<Item
348
348
isPacked={false}
349
-
name="Photo of Tam"
349
+
name="Foto od Tam"
350
350
/>
351
351
</ul>
352
352
</section>
@@ -358,15 +358,15 @@ export default function PackingList() {
358
358
359
359
<LearnMorepath="/learn/conditional-rendering">
360
360
361
-
Read **[Conditional Rendering](/learn/conditional-rendering)** to learn the different ways to render content conditionally.
361
+
Pročitajte**[Uslovno prikazivanje komponenti](/learn/conditional-rendering)**da biste naučili različite načine za uslovno prikazivanje sadržaja.
362
362
363
363
</LearnMore>
364
364
365
-
## Rendering lists {/*rendering-lists*/}
365
+
## Renderovanje liste {/*rendering-lists*/}
366
366
367
-
You will often want to display multiple similar components from a collection of data. You can use JavaScript's`filter()`and`map()`with React to filter and transform your array of data into an array of components.
367
+
Često ćete želeti da prikažete više sličnih komponenti iz kolekcije podataka. Možete koristiti JavaScript `filter()`i`map()`sa React-om da biste filtrirali i transformisali vaš niz podataka u niz komponenti.
368
368
369
-
For each array item, you will need to specify a `key`. Usually, you will want to use an IDfrom the database as a `key`. Keyslet React keep track of each item's place in the list even if the list changes.
369
+
Za svaki element u nizu, moraćete da odredite `key` prop. Obično ćete koristiti ID iz baze podataka kao `key`. Ključevi omogućavaju React-u da prati mesto svakog elementa u listi čak i ako se lista promeni.
370
370
371
371
<Sandpack>
372
372
@@ -384,7 +384,7 @@ export default function List() {
384
384
<p>
385
385
<b>{person.name}:</b>
386
386
{''+person.profession+''}
387
-
known for {person.accomplishment}
387
+
poznat je zbog {person.accomplishment}
388
388
</p>
389
389
</li>
390
390
);
@@ -402,31 +402,31 @@ export const people = [{
402
402
id:0,
403
403
name:'Creola Katherine Johnson',
404
404
profession:'mathematician',
405
-
accomplishment: 'spaceflight calculations',
405
+
accomplishment:'formula za svemirske letove',
406
406
imageId:'MK3eW3A'
407
407
}, {
408
408
id:1,
409
409
name:'Mario José Molina-Pasquel Henríquez',
410
410
profession:'chemist',
411
-
accomplishment: 'discovery of Arctic ozone hole',
411
+
accomplishment:'otkriće Arktičke rupe u ozonu',
412
412
imageId:'mynHUSa'
413
413
}, {
414
414
id:2,
415
415
name:'Mohammad Abdus Salam',
416
416
profession:'physicist',
417
-
accomplishment: 'electromagnetism theory',
417
+
accomplishment:'teorija o elektromagnetizmu',
418
418
imageId:'bE7W1ji'
419
419
}, {
420
420
id:3,
421
421
name:'Percy Lavon Julian',
422
422
profession:'chemist',
423
-
accomplishment: 'pioneering cortisone drugs, steroids and birth control pills',
423
+
accomplishment:'pionirski kortizon, steroide i pilule za kontrolu rađanja',
424
424
imageId:'IOjWm71'
425
425
}, {
426
426
id:4,
427
427
name:'Subrahmanyan Chandrasekhar',
428
428
profession:'astrophysicist',
429
-
accomplishment: 'white dwarf star mass calculations',
429
+
accomplishment:'računanje mase belog patuljka',
430
430
imageId:'lrWQx8l'
431
431
}];
432
432
```
@@ -458,18 +458,19 @@ h2 { font-size: 20px; }
458
458
459
459
<LearnMorepath="/learn/rendering-lists">
460
460
461
-
Read**[Rendering Lists](/learn/rendering-lists)**to learn how to render a list of components, and how to choose a key.
461
+
Pročitajte**[Renderovanje liste](/learn/rendering-lists)**da biste naučili kako da renderujete listu komponenti i kako da odaberete ključ.
462
462
463
463
</LearnMore>
464
464
465
-
## Keeping components pure {/*keeping-components-pure*/}
Some JavaScript functions are *pure.*A pure function:
467
+
Neke JavaScript funkcije su *čiste.*Čista funkcija:
468
468
469
-
***Minds its own business.** It does not change any objects or variables that existed before it was called.
470
-
***Same inputs, same output.** Given the same inputs, a pure function should always return the same result.
469
+
***Gleda svoj posao.** Ne zavisi od bilo kakvih globalnih promenljivih ili stanja aplikacije.
470
+
***Isti input, isti output.** Dajući isti input, čista funkcija uvek treba da vrati isti rezultat.
471
+
472
+
Striktno pisanje vaših komponenti kao čistih funkcija može da izbegne čitavu klasu zbunjujućih grešaka i nepredvidivog ponašanja kako vaša baza koda raste. Ovde je primer nečiste komponente:
471
473
472
-
By strictly only writing your components as pure functions, you can avoid an entire class of baffling bugs and unpredictable behavior as your codebase grows. Here is an example of an impure component:
473
474
474
475
<Sandpack>
475
476
@@ -479,7 +480,7 @@ let guest = 0;
479
480
functionCup() {
480
481
// Bad: changing a preexisting variable!
481
482
guest = guest +1;
482
-
return<h2>Tea cup for guest #{guest}</h2>;
483
+
return<h2>Šolja čaja za gosta #{guest}</h2>;
483
484
}
484
485
485
486
exportdefaultfunctionTeaSet() {
@@ -495,13 +496,13 @@ export default function TeaSet() {
495
496
496
497
</Sandpack>
497
498
498
-
You can make this component pure by passing a prop instead of modifying a preexisting variable:
499
+
Možete napraviti ovu komponentu čistom tako što ćete proslediti prop umesto što ćete modifikovati prethodno postojeću promenljivu:
499
500
500
501
<Sandpack>
501
502
502
503
```js
503
504
functionCup({ guest }) {
504
-
return<h2>Tea cup for guest #{guest}</h2>;
505
+
return<h2>Šolja čaja za gosta #{guest}</h2>;
505
506
}
506
507
507
508
exportdefaultfunctionTeaSet() {
@@ -519,12 +520,13 @@ export default function TeaSet() {
519
520
520
521
<LearnMorepath="/learn/keeping-components-pure">
521
522
522
-
Read**[Keeping Components Pure](/learn/keeping-components-pure)**to learn how to write components as pure, predictable functions.
523
+
Pročitajte**[Održavanje komponenti čistim](/learn/keeping-components-pure)**da biste naučili kako da napišete komponente kao čiste funkcije.
523
524
524
525
</LearnMore>
525
526
526
-
## What's next? {/*whats-next*/}
527
+
## Šta dalje? {/*whats-next*/}
528
+
529
+
Idite do [Vaša prva komponenta](/learn/your-first-component) da biste počeli da čitate ovo poglavlje stranicu po stranicu!
527
530
528
-
Head over to [Your First Component](/learn/your-first-component) to start reading this chapter page by page!
531
+
Ili ako ste već upoznati sa ovim temama, zašto ne biste pročitali o [Dodavanju interaktivnosti](/learn/adding-interactivity)?
529
532
530
-
Or, if you're already familiar with these topics, why not read about [Adding Interactivity](/learn/adding-interactivity)?
0 commit comments