Scientists
+Naučnici
- {listItems}
From 6600a219a7eddd579533d6fa643a5eb5d3e5acca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rado=C5=A1=20Mili=C4=87ev?=
<40705899+rammba@users.noreply.github.com>
Date: Wed, 27 Nov 2024 22:44:13 +0100
Subject: [PATCH] Translate rendering-lists.md
---
src/content/learn/rendering-lists.md | 456 +++++++++++++------------
src/content/learn/thinking-in-react.md | 2 +-
2 files changed, 235 insertions(+), 223 deletions(-)
diff --git a/src/content/learn/rendering-lists.md b/src/content/learn/rendering-lists.md
index 32f81c44..ef3244cf 100644
--- a/src/content/learn/rendering-lists.md
+++ b/src/content/learn/rendering-lists.md
@@ -1,74 +1,74 @@
---
-title: Rendering Lists
+title: Renderovanje listi
---
{person.name}: {' ' + person.profession + ' '} - known for {person.accomplishment} + poznat je zbog {person.accomplishment}
); ``` -3. Lastly, **return** the `listItems` from your component: +3. Na kraju, **vratite** `listItems` iz vaše komponente: ```js return{person.name}: {' ' + person.profession + ' '} - known for {person.accomplishment} + poznat je zbog {person.accomplishment}
{person.name} {' ' + person.profession + ' '} - known for {person.accomplishment} + poznat je zbog {person.accomplishment}
); @@ -318,34 +330,34 @@ export default function List() { ```js src/data.js active export const people = [{ - id: 0, // Used in JSX as a key + id: 0, // Koristi se u JSX kao ključ name: 'Creola Katherine Johnson', - profession: 'mathematician', - accomplishment: 'spaceflight calculations', + profession: 'matematičar', + accomplishment: 'formula za svemirske letove', imageId: 'MK3eW3A' }, { - id: 1, // Used in JSX as a key + id: 1, // Koristi se u JSX kao ključ name: 'Mario José Molina-Pasquel Henríquez', - profession: 'chemist', - accomplishment: 'discovery of Arctic ozone hole', + profession: 'hemičar', + accomplishment: 'otkriće Arktičke rupe u ozonu', imageId: 'mynHUSa' }, { - id: 2, // Used in JSX as a key + id: 2, // Koristi se u JSX kao ključ name: 'Mohammad Abdus Salam', - profession: 'physicist', - accomplishment: 'electromagnetism theory', + profession: 'fizičar', + accomplishment: 'teorija o elektromagnetizmu', imageId: 'bE7W1ji' }, { - id: 3, // Used in JSX as a key + id: 3, // Koristi se u JSX kao ključ name: 'Percy Lavon Julian', - profession: 'chemist', - accomplishment: 'pioneering cortisone drugs, steroids and birth control pills', + profession: 'hemičar', + accomplishment: 'pionirski kortizon, steroidi i pilule za kontrolu rađanja', imageId: 'IOjWm71' }, { - id: 4, // Used in JSX as a key + id: 4, // Koristi se u JSX kao ključ name: 'Subrahmanyan Chandrasekhar', - profession: 'astrophysicist', - accomplishment: 'white dwarf star mass calculations', + profession: 'astrofizičar', + accomplishment: 'računanje mase belog patuljka', imageId: 'lrWQx8l' }]; ``` @@ -376,11 +388,11 @@ img { width: 100px; height: 100px; border-radius: 50%; }`, `
`, and so on. +Fragment-i nestaju iz DOM-a, tako da ćete dobiti listu od `
`, `
`, i tako dalje.
-### Where to get your `key` {/*where-to-get-your-key*/}
+### Gde dobiti `key` {/*where-to-get-your-key*/}
-Different sources of data provide different sources of keys:
+Različiti izvori podataka pružaju različite ključeve:
-* **Data from a database:** If your data is coming from a database, you can use the database keys/IDs, which are unique by nature.
-* **Locally generated data:** If your data is generated and persisted locally (e.g. notes in a note-taking app), use an incrementing counter, [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) or a package like [`uuid`](https://www.npmjs.com/package/uuid) when creating items.
+* **Podaci iz baze podataka:** Ako podaci dolaze iz baze podataka, možete koristiti ključeve ili ID-eve iz baze podataka, koji su po prirodi jedinstveni.
+* **Lokalno generisani podaci:** Ako su vam podaci generisani i čuvani lokalno (npr. beleške u aplikaciji za zabeleške), koristite inkrementalni brojač, [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) ili pakete poput [`uuid`](https://www.npmjs.com/package/uuid) kada kreirate stavke.
-### Rules of keys {/*rules-of-keys*/}
+### Pravila ključeva {/*rules-of-keys*/}
-* **Keys must be unique among siblings.** However, it’s okay to use the same keys for JSX nodes in _different_ arrays.
-* **Keys must not change** or that defeats their purpose! Don't generate them while rendering.
+* **Ključevi moraju biti jedinstveni između „sestrinskih” stavki.** Međutim, u redu je koristiti iste ključeve za JSX čvorove u _različitim_ nizovima.
+* **Ključevi se ne smeju menjati** ili će im se svrha obesmisliti! Nemojte ih generisati tokom renderovanja.
-### Why does React need keys? {/*why-does-react-need-keys*/}
+### Zašto su React-u potrebni ključevi? {/*why-does-react-need-keys*/}
-Imagine that files on your desktop didn't have names. Instead, you'd refer to them by their order -- the first file, the second file, and so on. You could get used to it, but once you delete a file, it would get confusing. The second file would become the first file, the third file would be the second file, and so on.
+Zamislite da fajlovi na vašem desktop-u nemaju imena. Umesto toga, referencirali bi ih po njihovom redosledu -- prvi fajl, drugi fajl, i tako dalje. Mogli biste se navići, ali jednom kada obrišete fajl, postalo bi zbunjujuće. Drugi fajl bi postao prvi fajl, treći fajl bi postao drugi fajl, i tako dalje.
-File names in a folder and JSX keys in an array serve a similar purpose. They let us uniquely identify an item between its siblings. A well-chosen key provides more information than the position within the array. Even if the _position_ changes due to reordering, the `key` lets React identify the item throughout its lifetime.
+Imena fajlova u folderu i JSX ključevi imaju sličnu ulogu. Omogućavaju nam da jedinstveno identifikujemo stavku među „sestrinskim” stavkama. Dobro odabran ključ pruža više informacija od puke pozicije u nizu. Čak iako se _pozicija_ promeni zbog promene redosleda, `key` omogućava React-u da identifikuje stavku tokom njenog životnog veka.
{person.name}:
{' ' + person.profession + ' '}
- known for {person.accomplishment}
+ poznat je zbog {person.accomplishment}
{person.name}:
{' ' + person.profession + ' '}
- known for {person.accomplishment}
+ poznat je zbog {person.accomplishment}
{person.name}:
{' ' + person.profession + ' '}
- known for {person.accomplishment}
+ poznat je zbog {person.accomplishment}
{person.name}:
{' ' + person.profession + ' '}
- known for {person.accomplishment}
+ poznat je zbog {person.accomplishment}
{person.name}:
{' ' + person.profession + ' '}
- known for {person.accomplishment}
+ poznat je zbog {person.accomplishment}
` tag. Your job is to insert an ` ` tag-om. Vaš posao je da ubacite ` ` elements, not in the beginning or the end!
+Haiku sadrži samo tri linije, ali vaše rešenje treba raditi za bilo koji broj linija. Zapazite da se ` ` elemenata, ali ne na početku i kraju!
... ... ... ...Scientists
+ Naučnici
{listItems}
Scientists
- Chemists
+ Naučnici
+ Hemičari
{chemists.map(person =>
- Everyone Else
+ Svi ostali
{everyoneElse.map(person =>
` elements, but you could introduce variables for them if you find that more readable.
+U ovom rešenju, `map` pozivi su smešteni direktno unutar roditeljskih `
` elemenata, ali možete uvesti promenljive za njih ako vam to deluje čitljivije.
-There is still a bit duplication between the rendered lists. You can go further and extract the repetitive parts into a `
Scientists
+ Naučnici
Scientists
+ Naučnici
` and list its ingredients in a `
`.
+Napravite listu recepata od ovog niza! Za svaki recept u nizu, prikažite mu ime kao `
` i listu sastojaka u `
`-u.
Recipes
+ Recepti
Recipes
+ Recepti
{recipes.map(recipe =>
{recipe.name}
@@ -959,28 +971,28 @@ export default function RecipeList() {
```js src/data.js
export const recipes = [{
id: 'greek-salad',
- name: 'Greek Salad',
- ingredients: ['tomatoes', 'cucumber', 'onion', 'olives', 'feta']
+ name: 'Grčka salata',
+ ingredients: ['paradajz', 'krastavci', 'crni luk', 'masline', 'feta']
}, {
id: 'hawaiian-pizza',
- name: 'Hawaiian Pizza',
- ingredients: ['pizza crust', 'pizza sauce', 'mozzarella', 'ham', 'pineapple']
+ name: 'Havajska pica',
+ ingredients: ['kora za picu', 'sos za picu', 'mocarela', 'šunka', 'ananas']
}, {
id: 'hummus',
- name: 'Hummus',
- ingredients: ['chickpeas', 'olive oil', 'garlic cloves', 'lemon', 'tahini']
+ name: 'Humus',
+ ingredients: ['leblebija', 'maslinovo ulje', 'čen belog luka', 'limun', 'tahini']
}];
```
-Each of the `recipes` already includes an `id` field, so that's what the outer loop uses for its `key`. There is no ID you could use to loop over ingredients. However, it's reasonable to assume that the same ingredient won't be listed twice within the same recipe, so its name can serve as a `key`. Alternatively, you could change the data structure to add IDs, or use index as a `key` (with the caveat that you can't safely reorder ingredients).
+Svaka stavka u `recipes` već uključuje `id` polje, tako da se to koristi kao `key` u spoljašnjoj petlji. Ne postoji ID koji možete koristiti da prolazite kroz sastojke. Međutim, razumno je pretpostaviti da isti sastojak neće biti dvaput nabrojan u jednom receptu, tako da njegovo ime može služiti kao `key`. Alternativno, možete promeniti strukturu podataka i dodati ID-eve, ili koristiti indeks kao `key` (uz upozorenje da ne možete sigurno menjati redosled sastojaka).
-#### Extracting a list item component {/*extracting-a-list-item-component*/}
+#### Izdvojiti stavku liste u komponentu {/*extracting-a-list-item-component*/}
-This `RecipeList` component contains two nested `map` calls. To simplify it, extract a `Recipe` component from it which will accept `id`, `name`, and `ingredients` props. Where do you place the outer `key` and why?
+Ova `RecipeList` komponenta sadrži dva ugnježdena `map` poziva. Da biste je pojednostavili, izdvojite `Recipe` komponentu iz nje koja će primiti `id`, `name` i `ingredients` props-e. Gde ćete smestiti spoljašni `key` i zašto?
Recipes
+ Recepti
{recipes.map(recipe =>
{recipe.name}
@@ -1011,16 +1023,16 @@ export default function RecipeList() {
```js src/data.js
export const recipes = [{
id: 'greek-salad',
- name: 'Greek Salad',
- ingredients: ['tomatoes', 'cucumber', 'onion', 'olives', 'feta']
+ name: 'Grčka salata',
+ ingredients: ['paradajz', 'krastavci', 'crni luk', 'masline', 'feta']
}, {
id: 'hawaiian-pizza',
- name: 'Hawaiian Pizza',
- ingredients: ['pizza crust', 'pizza sauce', 'mozzarella', 'ham', 'pineapple']
+ name: 'Havajska pica',
+ ingredients: ['kora za picu', 'sos za picu', 'mocarela', 'šunka', 'ananas']
}, {
id: 'hummus',
- name: 'Hummus',
- ingredients: ['chickpeas', 'olive oil', 'garlic cloves', 'lemon', 'tahini']
+ name: 'Humus',
+ ingredients: ['leblebija', 'maslinovo ulje', 'čen belog luka', 'limun', 'tahini']
}];
```
@@ -1028,7 +1040,7 @@ export const recipes = [{
Recipes
+ Recepti
{recipes.map(recipe =>
` separator between each paragraph. Your resulting structure should look like this:
+Ovaj primer renderuje poznatu haiku koju je napisao Tachibana Hokushi, gde je svaka linija obmotana `
` separator između paragrafa. Rezultat treba da izgleda ovako:
```js
` elements only appear *between* the `
` elementi pojavljuju samo *između* `
` and `
` i `
@@ -1180,7 +1192,7 @@ export default function Poem() {
+ // Obrišite prvi
output.shift();
return (
@@ -1208,9 +1220,9 @@ hr {
-Using the original line index as a `key` doesn't work anymore because each separator and paragraph are now in the same array. However, you can give each of them a distinct key using a suffix, e.g. `key={i + '-text'}`.
+Upotreba indeksa originalne linije za `key` više ne radi jer su i separatori i paragrafi sada u istom nizu. Međutim, svakom od njih možete dati jedinstven ključ upotrebom sufiksa, npr. `key={i + '-text'}`.
-Alternatively, you could render a collection of Fragments which contain `
` and `
` i `