diff --git a/src/content/learn/adding-interactivity.md b/src/content/learn/adding-interactivity.md
index 128b330f..91ba1205 100644
--- a/src/content/learn/adding-interactivity.md
+++ b/src/content/learn/adding-interactivity.md
@@ -68,11 +68,11 @@ button { margin-right: 10px; }
-Pročitajte **[Odgovaranje na Event-e](/learn/responding-to-events)** da biste naučili kako da dodate event handler-e.
+Pročitajte **[Odgovaranje na event-e](/learn/responding-to-events)** da biste naučili kako da dodate event handler-e.
-## State: memorija component-e {/*state-a-components-memory*/}
+## State: Memorija component-e {/*state-a-components-memory*/}
Component-e često moraju da promene ono što je prikazano na ekranu kao rezultat neke interakcije. Kucanje u formu treba da update-uje polje za unos, klik na "sledeće" u karuselu slika treba da promeni prikazanu sliku, klik na "kupi" stavlja proizvod u korpu. Component-e moraju da "pamte" određene stvari: trenutnu vrednost unosa, trenutnu sliku, korpu za kupovinu. U React-u, ova vrsta memorije specifična za component-e naziva se *state.*
diff --git a/src/content/learn/editor-setup.md b/src/content/learn/editor-setup.md
index 404514bc..4f9909d5 100644
--- a/src/content/learn/editor-setup.md
+++ b/src/content/learn/editor-setup.md
@@ -33,7 +33,7 @@ Neki editori dolaze sa ugrađenim funkcijama, dok drugi zahtevaju dodavanje ekst
Linting alati pronalaze probleme u vašem kodu dok ga pišete, pomažući vam da ih ispravite na vreme. [ESLint](https://eslint.org/) je popularan open source linter za JavaScript.
-* [Instalirajte ESLint sa preporučenom konfiguracijom za React](https://www.npmjs.com/package/eslint-config-react-app) (budite sigurni da imate [Node instaliran!](https://nodejs.org/en/download/current/))
+* [Instalirajte ESLint sa preporučenom konfiguracijom za React](https://www.npmjs.com/package/eslint-config-react-app) (budite sigurni da imate [instaliran Node](https://nodejs.org/en/download/current/)!)
* [Integrišite ESLint u VSCode sa zvaničnom ekstenzijom](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
**Budite sigurni da ste omogućili sva [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks) pravila za vaš projekat.** Oni su esencijalni i hvataju najozbiljnije greške na vreme. Preporučena [`eslint-config-react-app`](https://www.npmjs.com/package/eslint-config-react-app) konfiguracija već ih uključuje.
diff --git a/src/content/learn/index.md b/src/content/learn/index.md
index 40eae1a7..a45b1ee3 100644
--- a/src/content/learn/index.md
+++ b/src/content/learn/index.md
@@ -316,7 +316,7 @@ function MyButton() {
// ...
```
-Od `useState` dobićete 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]`.
+Od `useState` dobićete 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 `[something, setSomething]`.
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č:
diff --git a/src/content/learn/state-a-components-memory.md b/src/content/learn/state-a-components-memory.md
index 75a1fd0b..d994c544 100644
--- a/src/content/learn/state-a-components-memory.md
+++ b/src/content/learn/state-a-components-memory.md
@@ -1,25 +1,25 @@
---
-title: "State: A Component's Memory"
+title: "State: Memorija komponente"
---
-Components often need to change what's on the screen as a result of an interaction. Typing into the form should update the input field, clicking "next" on an image carousel should change which image is displayed, clicking "buy" should put a product in the shopping cart. Components need to "remember" things: the current input value, the current image, the shopping cart. In React, this kind of component-specific memory is called *state*.
+Komponente često trebaju promeniti prikaz na ekranu u zavisnosti od interakcija. Pisanje u formu bi trebalo da osveži input polje, klik na "naredno" u carousel-u za slike treba promeniti prikazanu sliku, klik na "kupi" bi trebao da stavi proizvod u korpu. Komponente trebaju da "pamte" stvari: trenutnu vrednost input-a, trenutnu sliku, korpu sa proizvodima. U React-u, ova vrsta memorije koja je specifična za komponentu se naziva *state*.
-* How to add a state variable with the [`useState`](/reference/react/useState) Hook
-* What pair of values the `useState` Hook returns
-* How to add more than one state variable
-* Why state is called local
+* Kako da dodate state promenljivu sa [`useState`](/reference/react/useState) Hook-om
+* Koji par vrednosti vraća `useState` Hook
+* Kako da dodate više od jedne state promenljive
+* Zašto se state naziva lokalnim
-## When a regular variable isn’t enough {/*when-a-regular-variable-isnt-enough*/}
+## Kad obična promenljiva nije dovoljna {/*when-a-regular-variable-isnt-enough*/}
-Here's a component that renders a sculpture image. Clicking the "Next" button should show the next sculpture by changing the `index` to `1`, then `2`, and so on. However, this **won't work** (you can try it!):
+Ovde je komponenta koja renderuje sliku skulpture. Klikom na dugme "Naredno" trebala bi se prikazati naredna skulptura promenom `index` promenljive na `1`, pa na `2` i tako dalje. Međutim, ovo **neće raditi** (možete probati!):
@@ -37,14 +37,14 @@ export default function Gallery() {
return (
<>
{sculpture.name}
- by {sculpture.artist}
+ napravio/la {sculpture.artist}
- ({index + 1} of {sculptureList.length})
+ ({index + 1} od {sculptureList.length})
-The `handleClick` event handler is updating a local variable, `index`. But two things prevent that change from being visible:
+`handleClick` event handler ažurira lokalnu promenljivu `index`. Ali, dve stvari sprečavaju tu promenu da bude primenjena:
-1. **Local variables don't persist between renders.** When React renders this component a second time, it renders it from scratch—it doesn't consider any changes to the local variables.
-2. **Changes to local variables won't trigger renders.** React doesn't realize it needs to render the component again with the new data.
+1. **Lokalne promenljive se ne čuvaju između rendera.** Kada React renderuje komponentu drugi put, renderuje je iznova—ne uzima u obzir nikakve promene u lokalnim promenljivama.
+2. **Promene lokalnih promenljiva neće okinuti renderovanje.** React ne shvata da treba da renderuje komponentu ponovo sa novim podacima.
-To update a component with new data, two things need to happen:
+Da biste ažurirali komponentu sa novim podacima, potrebne su dve stvari:
-1. **Retain** the data between renders.
-2. **Trigger** React to render the component with new data (re-rendering).
+1. **Zadržavanje** podataka između rendera.
+2. **Okidanje** renderovanja komponente sa novim podacima (ponovno renderovanje).
-The [`useState`](/reference/react/useState) Hook provides those two things:
+[`useState`](/reference/react/useState) Hook omogućava te dve stvari:
-1. A **state variable** to retain the data between renders.
-2. A **state setter function** to update the variable and trigger React to render the component again.
+1. **state promenljiva** zadržava podatke između rendera.
+2. **state setter funkcija** ažurira promenljivu i tera React da okine renderovanje komponente ponovo.
-## Adding a state variable {/*adding-a-state-variable*/}
+## Dodavanje state promenljive {/*adding-a-state-variable*/}
-To add a state variable, import `useState` from React at the top of the file:
+Da bi ste dodali state promenljivu, import-ujte `useState` iz React-a na vrhu fajla:
```js
import { useState } from 'react';
```
-Then, replace this line:
+Onda, zamenite ovu liniju:
```js
let index = 0;
```
-with
+sa
```js
const [index, setIndex] = useState(0);
```
-`index` is a state variable and `setIndex` is the setter function.
+`index` je state promenljiva, a `setIndex` je setter funkcija.
-> The `[` and `]` syntax here is called [array destructuring](https://javascript.info/destructuring-assignment) and it lets you read values from an array. The array returned by `useState` always has exactly two items.
+> Sintaksa sa `[` i `]` se naziva [dekonstruisanje niza](https://javascript.info/destructuring-assignment) i omogućava vam da čitate vrednosti iz niza. Niz koji `useState` vraća uvek ima tačno dva člana.
-This is how they work together in `handleClick`:
+Evo kako rade zajedno u `handleClick`:
```js
function handleClick() {
@@ -198,7 +198,7 @@ function handleClick() {
}
```
-Now clicking the "Next" button switches the current sculpture:
+Sada, klikom na dugme "Naredno" promeniće se odabrana skulptura:
@@ -217,14 +217,14 @@ export default function Gallery() {
return (
<>
{sculpture.name}
- by {sculpture.artist}
+ napravio/la {sculpture.artist}
- ({index + 1} of {sculptureList.length})
+ ({index + 1} od {sculptureList.length})
-### Meet your first Hook {/*meet-your-first-hook*/}
+### Upoznajte svoj prvi Hook {/*meet-your-first-hook*/}
-In React, `useState`, as well as any other function starting with "`use`", is called a Hook.
+U React-u, `useState`, kao i ostale funkcije koje počinju sa "`use`", naziva se Hook.
-*Hooks* are special functions that are only available while React is [rendering](/learn/render-and-commit#step-1-trigger-a-render) (which we'll get into in more detail on the next page). They let you "hook into" different React features.
+*Hook-ovi* su specijalne funkcije koje su dostupne isključivo u toku React [renderovanja](/learn/render-and-commit#step-1-trigger-a-render) (što ćemo objasniti detaljnije na narednoj stranici). Omogućavaju vam da "se zakačite" za različite funkcionalnosti React-a.
-State is just one of those features, but you will meet the other Hooks later.
+State je samo jedna od tih funkcionalnosti, ali ćete upoznati i ostale Hook-ove kasnije.
-**Hooks—functions starting with `use`—can only be called at the top level of your components or [your own Hooks.](/learn/reusing-logic-with-custom-hooks)** You can't call Hooks inside conditions, loops, or other nested functions. Hooks are functions, but it's helpful to think of them as unconditional declarations about your component's needs. You "use" React features at the top of your component similar to how you "import" modules at the top of your file.
+**Hook-ovi—funkcije koje počinju sa `use`—mogu biti pozvane samo na početku vaših komponenata ili [vaših Hooks-ova](/learn/reusing-logic-with-custom-hooks)**. Ne možete pozivati Hook-ove unutar uslova, petlji, ili drugih ugnježdenih funkcija. Hook-ovi su funkcije, ali je korisno da na njih gledate kao bezuslovne deklaracije onoga što je komponenti potrebno. "Koristite" React funkcionalnosti na vrhu komponente slično kao što "import-ujete" module na vrhu fajla.
-### Anatomy of `useState` {/*anatomy-of-usestate*/}
+### Anatomija `useState`-a {/*anatomy-of-usestate*/}
-When you call [`useState`](/reference/react/useState), you are telling React that you want this component to remember something:
+Kada pozovete [`useState`](/reference/react/useState), govorite React-u da želite da ta komponenta nešto zapamti:
```js
const [index, setIndex] = useState(0);
```
-In this case, you want React to remember `index`.
+U ovom slučaju, želite da React zapamti `index`.
-The convention is to name this pair like `const [something, setSomething]`. You could name it anything you like, but conventions make things easier to understand across projects.
+Konvencija je da se par nazove ovako `const [something, setSomething]`. Možete staviti bilo koja imena, ali konvencije čine kod lakšim za razumevanje na različitim projektima.
-The only argument to `useState` is the **initial value** of your state variable. In this example, the `index`'s initial value is set to `0` with `useState(0)`.
+Jedini argument u `useState` je **inicijalna vrednost** vaše state promenljive. U ovom primeru, inicijalna vrednost `index`-a je postavljena na `0` sa `useState(0)`.
-Every time your component renders, `useState` gives you an array containing two values:
+Svaki put kad se komponenta renderuje, `useState` vam daje niz koji sadrži dve vrednosti:
-1. The **state variable** (`index`) with the value you stored.
-2. The **state setter function** (`setIndex`) which can update the state variable and trigger React to render the component again.
+1. **state promenljiva** (`index`) sa vrednošću koju ste sačuvali.
+2. **state setter funkcija** (`setIndex`) koja može da ažurira state promenljivu i natera React da okine renderovanje komponente ponovo.
-Here's how that happens in action:
+Evo toga i u praksi:
```js
const [index, setIndex] = useState(0);
```
-1. **Your component renders the first time.** Because you passed `0` to `useState` as the initial value for `index`, it will return `[0, setIndex]`. React remembers `0` is the latest state value.
-2. **You update the state.** When a user clicks the button, it calls `setIndex(index + 1)`. `index` is `0`, so it's `setIndex(1)`. This tells React to remember `index` is `1` now and triggers another render.
-3. **Your component's second render.** React still sees `useState(0)`, but because React *remembers* that you set `index` to `1`, it returns `[1, setIndex]` instead.
-4. And so on!
+1. **Vaša komponenta se renderuje prvi put.** Pošto ste prosledili `0` u `useState` kao inicijalnu vrednost za `index`, vratiće `[0, setIndex]`. React pamti da je `0` poslednja state vrednost.
+2. **Ažurirate state.** Kada korisnik klikne na dugme poziva se `setIndex(index + 1)`. `index` je `0`, tako da je to `setIndex(1)`. Ovo govori React-u da zapamti da je `index` sada `1` i okida novi render.
+3. **Drugo renderovanje vaše komponente.** React i dalje vidi `useState(0)`, ali zato što React *pamti* da ste setovali `index` na `1`, vratiće `[1, setIndex]`.
+4. I tako dalje!
-## Giving a component multiple state variables {/*giving-a-component-multiple-state-variables*/}
+## Davanje komponenti više state promenljivih {/*giving-a-component-multiple-state-variables*/}
-You can have as many state variables of as many types as you like in one component. This component has two state variables, a number `index` and a boolean `showMore` that's toggled when you click "Show details":
+Možete imati koliko god state promenljivih sa koliko god tipova podataka želite u jednoj komponenti. Ova komponenta ima dve state promenljive, broj `index` i boolean `showMore` koji se menja klikom na "Prikaži detalje":
@@ -405,17 +405,17 @@ export default function Gallery() {
return (
<>
{sculpture.name}
- by {sculpture.artist}
+ napravio/la {sculpture.artist}
- ({index + 1} of {sculptureList.length})
+ ({index + 1} od {sculptureList.length})
{showMore &&
{sculpture.description}
}
-It is a good idea to have multiple state variables if their state is unrelated, like `index` and `showMore` in this example. But if you find that you often change two state variables together, it might be easier to combine them into one. For example, if you have a form with many fields, it's more convenient to have a single state variable that holds an object than state variable per field. Read [Choosing the State Structure](/learn/choosing-the-state-structure) for more tips.
+Dobra je ideja imati više state promenljivih ako im state-ovi nisu povezani, kao `index` i `showMore` u ovom primeru. Ali, ako primetite da često menjate dve state promenljive zajedno, može biti lakše da ih grupišete u jednu. Na primer, ako imate formu sa mnogo polja, zgodnije je imati jednu state promenljivu koja drži ceo objekat, umesto jedne state promenljive po polju. Pročitajte [Odabir state strukture](/learn/choosing-the-state-structure) za više detalja.
-#### How does React know which state to return? {/*how-does-react-know-which-state-to-return*/}
+#### Kako React zna koji state da vrati? {/*how-does-react-know-which-state-to-return*/}
-You might have noticed that the `useState` call does not receive any information about *which* state variable it refers to. There is no "identifier" that is passed to `useState`, so how does it know which of the state variables to return? Does it rely on some magic like parsing your functions? The answer is no.
+Možda ste već primetili da `useState` poziv ne prima informaciju o tome na *koju* state promenljivu se odnosi. Ne postoji "identifikator" koji se prosleđuje u `useState`, pa kako onda zna koju od state promenljivih da vrati? Da li se oslanja na neku magiju poput parsiranja vaših funkcija? Odgovor je ne.
-Instead, to enable their concise syntax, Hooks **rely on a stable call order on every render of the same component.** This works well in practice because if you follow the rule above ("only call Hooks at the top level"), Hooks will always be called in the same order. Additionally, a [linter plugin](https://www.npmjs.com/package/eslint-plugin-react-hooks) catches most mistakes.
+Umesto toga, da bi omogućili svoju konciznu sintaksu, Hook-ovi **se oslanjaju na stabilan redosled poziva pri svakom renderovanju jedne komponente**. Ovo radi veoma dobro u praksi, jer ako pratite pravilo od gore ("pozivajte Hook-ove samo na početku"), Hook-ovi će uvek biti pozvani u istom redosledu. Dodatno, [linter plugin](https://www.npmjs.com/package/eslint-plugin-react-hooks) hvata većinu grešaka.
-Internally, React holds an array of state pairs for every component. It also maintains the current pair index, which is set to `0` before rendering. Each time you call `useState`, React gives you the next state pair and increments the index. You can read more about this mechanism in [React Hooks: Not Magic, Just Arrays.](https://medium.com/@ryardley/react-hooks-not-magic-just-arrays-cd4f1857236e)
+Interno, React čuva niz state parova za svaku komponentu. Takođe održava i trenutni indeks para koji je postavljen na `0` pre renderovanja. Svaki put kad pozovete `useState`, React vam daje naredni state par i povećava indeks. Možete pročitati više o ovom mehanizmu u [React Hook-ovi: Nije magija, već samo nizovi](https://medium.com/@ryardley/react-hooks-not-magic-just-arrays-cd4f1857236e).
-This example **doesn't use React** but it gives you an idea of how `useState` works internally:
+Ovaj primer **ne koristi React**, ali vam daje ideju kako `useState` zapravo radi:
@@ -540,37 +540,37 @@ This example **doesn't use React** but it gives you an idea of how `useState` wo
let componentHooks = [];
let currentHookIndex = 0;
-// How useState works inside React (simplified).
+// Kako useState radi unutar React-a (pojednostavljeno).
function useState(initialState) {
let pair = componentHooks[currentHookIndex];
if (pair) {
- // This is not the first render,
- // so the state pair already exists.
- // Return it and prepare for next Hook call.
+ // Ovo nije prvi render,
+ // tako da state par već postoji.
+ // Vrati ga i pripremi se za naredni Hook poziv.
currentHookIndex++;
return pair;
}
- // This is the first time we're rendering,
- // so create a state pair and store it.
+ // Ovo je prvi put da renderujemo,
+ // tako da kreiraj state par i sačuvaj ga.
pair = [initialState, setState];
function setState(nextState) {
- // When the user requests a state change,
- // put the new value into the pair.
+ // Kada korisnik zatraži promenu state-a,
+ // postavi novu vrednost u par.
pair[0] = nextState;
updateDOM();
}
- // Store the pair for future renders
- // and prepare for the next Hook call.
+ // Sačuvaj par za naredna renderovanja
+ // i pripremi se za naredni Hook poziv.
componentHooks[currentHookIndex] = pair;
currentHookIndex++;
return pair;
}
function Gallery() {
- // Each useState() call will get the next pair.
+ // Svaki useState() poziv će dobiti naredni par.
const [index, setIndex] = useState(0);
const [showMore, setShowMore] = useState(false);
@@ -583,14 +583,14 @@ function Gallery() {
}
let sculpture = sculptureList[index];
- // This example doesn't use React, so
- // return an output object instead of JSX.
+ // Ovaj primer ne koristi React, pa
+ // vrati objekat umesto JSX-a kao rezultat.
return {
onNextClick: handleNextClick,
onMoreClick: handleMoreClick,
- header: `${sculpture.name} by ${sculpture.artist}`,
- counter: `${index + 1} of ${sculptureList.length}`,
- more: `${showMore ? 'Hide' : 'Show'} details`,
+ header: `${sculpture.name} napravio/la ${sculpture.artist}`,
+ counter: `${index + 1} od ${sculptureList.length}`,
+ more: `${showMore ? 'Sakrij' : 'Prikaži'} detalje`,
description: showMore ? sculpture.description : null,
imageSrc: sculpture.url,
imageAlt: sculpture.alt
@@ -598,13 +598,13 @@ function Gallery() {
}
function updateDOM() {
- // Reset the current Hook index
- // before rendering the component.
+ // Resetuj trenutni indeks Hook-a
+ // pre renderovanja komponente.
currentHookIndex = 0;
let output = Gallery();
- // Update the DOM to match the output.
- // This is the part React does for you.
+ // Osveži DOM da se poklapa sa rezultatom.
+ // Ovo je deo koji React radi za vas.
nextButton.onclick = output.onNextClick;
header.textContent = output.header;
moreButton.onclick = output.onMoreClick;
@@ -627,84 +627,84 @@ let image = document.getElementById('image');
let sculptureList = [{
name: 'Homenaje a la Neurocirugía',
artist: 'Marta Colvin Andrade',
- description: 'Although Colvin is predominantly known for abstract themes that allude to pre-Hispanic symbols, this gigantic sculpture, an homage to neurosurgery, is one of her most recognizable public art pieces.',
+ description: 'Iako je Marta Colvin pretežno poznata po apstraktnim temama koje aludiraju na pre-hispanske simbole, ova ogromna skulptura, koja je omaž neurohirurgiji, jedna je od njenih najpoznatijih remek dela.',
url: 'https://i.imgur.com/Mx7dA2Y.jpg',
- alt: 'A bronze statue of two crossed hands delicately holding a human brain in their fingertips.'
+ alt: 'Bronzana statua dve skrštene ruke koje pažljivo drže ljudski mozak vrhovima prstiju.'
}, {
name: 'Floralis Genérica',
artist: 'Eduardo Catalano',
- description: 'This enormous (75 ft. or 23m) silver flower is located in Buenos Aires. It is designed to move, closing its petals in the evening or when strong winds blow and opening them in the morning.',
+ description: 'Ovaj ogromni (75 ft. ili 23m) srebrni cvet se nalazi u Buenos Ajresu. Dizajniran je da se pomera, zatvarajući svoje latice uveče ili kada duvaju jaki vetrovi, a otvarajući ih ujutru.',
url: 'https://i.imgur.com/ZF6s192m.jpg',
- alt: 'A gigantic metallic flower sculpture with reflective mirror-like petals and strong stamens.'
+ alt: 'Velika metalna skulptura cveta sa reflektujućim laticama nalik na ogledalo i snažnim prašnicima.'
}, {
name: 'Eternal Presence',
artist: 'John Woodrow Wilson',
- description: 'Wilson was known for his preoccupation with equality, social justice, as well as the essential and spiritual qualities of humankind. This massive (7ft. or 2,13m) bronze represents what he described as "a symbolic Black presence infused with a sense of universal humanity."',
+ description: 'Wilson je poznat po svojoj preokupiranosti jednakošću, socijalnom pravdom, kao i suštinskim i duhovnim kvalitetima čovečanstva. Ova masivna (7ft. ili 2,13m) bronzana skulptura predstavlja ono što je on objasnio kao "simbolično crno prisustvo prožeto osećajem univerzalne humanosti".',
url: 'https://i.imgur.com/aTtVpES.jpg',
- alt: 'The sculpture depicting a human head seems ever-present and solemn. It radiates calm and serenity.'
+ alt: 'Skulptura ljudske glave koja deluje sveprisutno i svečano. Zrači mirnoćom i spokojstvom.'
}, {
name: 'Moai',
- artist: 'Unknown Artist',
- description: 'Located on the Easter Island, there are 1,000 moai, or extant monumental statues, created by the early Rapa Nui people, which some believe represented deified ancestors.',
+ artist: 'Nepoznati umetnik',
+ description: 'Nalazi se na Uskršnjem ostrvu, gde postoji oko 1,000 moai očuvanih monumentalnih skulptura, koje su napravili prvobitni Rapa Nui ljudi, za koje se veruje da predstavljaju pretke Bogova.',
url: 'https://i.imgur.com/RCwLEoQm.jpg',
- alt: 'Three monumental stone busts with the heads that are disproportionately large with somber faces.'
+ alt: 'Tri monumentalne biste sa neproporcionalno velikim glavama i namrštenim licima.'
}, {
name: 'Blue Nana',
artist: 'Niki de Saint Phalle',
- description: 'The Nanas are triumphant creatures, symbols of femininity and maternity. Initially, Saint Phalle used fabric and found objects for the Nanas, and later on introduced polyester to achieve a more vibrant effect.',
+ description: 'Nane su trijumfalna stvorenja, simboli ženstvenosti i majčinstva. Inicijalno, Saint Phalle je koristila tkaninu i pronađene objekte za Nane, ali je kasnije uvela poliester kako bi napravila živopisniji dojam.',
url: 'https://i.imgur.com/Sd1AgUOm.jpg',
- alt: 'A large mosaic sculpture of a whimsical dancing female figure in a colorful costume emanating joy.'
+ alt: 'Velika mozaička skulptura neobične ženske figure u raznobojnom kostimu koji odiše radošću.'
}, {
name: 'Ultimate Form',
artist: 'Barbara Hepworth',
- description: 'This abstract bronze sculpture is a part of The Family of Man series located at Yorkshire Sculpture Park. Hepworth chose not to create literal representations of the world but developed abstract forms inspired by people and landscapes.',
+ description: 'Ova apstraktna bronzana skulptura je deo The Family of Man serije koja se nalazi u Jorkširskom parku skulptura. Hepworth je odlučila da ne pravi bukvalne reprezentacije sveta, već apstraktne forme inspirisane ljudima i pejzažima.',
url: 'https://i.imgur.com/2heNQDcm.jpg',
- alt: 'A tall sculpture made of three elements stacked on each other reminding of a human figure.'
+ alt: 'Visoka skulptura tri elementa jedna na drugom koja podseća na ljudsku figuru.'
}, {
name: 'Cavaliere',
artist: 'Lamidi Olonade Fakeye',
- description: "Descended from four generations of woodcarvers, Fakeye's work blended traditional and contemporary Yoruba themes.",
+ description: "Pošto potiče od četiri generacije drvorezbara, Fakeye-ova dela su mešavina tradicionalne i savremene Joruba tematike.",
url: 'https://i.imgur.com/wIdGuZwm.png',
- alt: 'An intricate wood sculpture of a warrior with a focused face on a horse adorned with patterns.'
+ alt: 'Složena drvena skulptura ratnika čije lice je fokusirano na konja ukrašenim šarama.'
}, {
name: 'Big Bellies',
artist: 'Alina Szapocznikow',
- description: "Szapocznikow is known for her sculptures of the fragmented body as a metaphor for the fragility and impermanence of youth and beauty. This sculpture depicts two very realistic large bellies stacked on top of each other, each around five feet (1,5m) tall.",
+ description: "Alina je poznata po skulpturama izdeljenog tela kao metafore za krhkost i nestalnost mladosti i lepote. Ova skulptura prikazuje dva veoma realistična velika stomaka jednog na drugom, gde je svaki visok oko 5 stopa (1,5m).",
url: 'https://i.imgur.com/AlHTAdDm.jpg',
- alt: 'The sculpture reminds a cascade of folds, quite different from bellies in classical sculptures.'
+ alt: 'Ova skulptura podseća na slapove nabora i dosta se razlikuje od stomaka na klasičnim skulpturama.'
}, {
name: 'Terracotta Army',
- artist: 'Unknown Artist',
- description: 'The Terracotta Army is a collection of terracotta sculptures depicting the armies of Qin Shi Huang, the first Emperor of China. The army consisted of more than 8,000 soldiers, 130 chariots with 520 horses, and 150 cavalry horses.',
+ artist: 'Nepoznati umetnik',
+ description: 'Terracotta Army je kolekcija terakota skulptura koje predstavljaju armiju Qin Shi Huang-a, prvog cara Kine. Armija se sastojala od preko 8,000 vojnika, 130 kola sa 520 konja i 150 članova konjice.',
url: 'https://i.imgur.com/HMFmH6m.jpg',
- alt: '12 terracotta sculptures of solemn warriors, each with a unique facial expression and armor.'
+ alt: '12 terakota skulptura svečanih vojnika, od kojih svaki ima jedinstvenu facijalnu ekspresiju i oklop.'
}, {
name: 'Lunar Landscape',
artist: 'Louise Nevelson',
- description: 'Nevelson was known for scavenging objects from New York City debris, which she would later assemble into monumental constructions. In this one, she used disparate parts like a bedpost, juggling pin, and seat fragment, nailing and gluing them into boxes that reflect the influence of Cubism’s geometric abstraction of space and form.',
+ description: 'Nevelson je poznata po uklanjanju objekata iz ruševina Njujorka, od kojih je kasnije pravila monumentalne konstrukcije. Za ovo je koristila rasparene delove poput noge od kreveta, palice za žongliranje i delove sedišta, zakucavajući ih i lepeći u kutije koje podsećaju na kubističku geometrijsku apstrakciju prostora i forme.',
url: 'https://i.imgur.com/rN7hY6om.jpg',
- alt: 'A black matte sculpture where the individual elements are initially indistinguishable.'
+ alt: 'Crna mat skulptura gde su pojedinačni delovi na početku bili neprimetni.'
}, {
name: 'Aureole',
artist: 'Ranjani Shettar',
- description: 'Shettar merges the traditional and the modern, the natural and the industrial. Her art focuses on the relationship between man and nature. Her work was described as compelling both abstractly and figuratively, gravity defying, and a "fine synthesis of unlikely materials."',
+ description: 'Shettar spaja tradicionalno i moderno, prirodno i industrijsko. Njena umetnost se fokusira na vezu između čoveka i prirode. Njen rad se opisuje kao ubedljiv i apstraktno i figurativno, prokoseći gravitaciji, kao i "dobra sinteza neobičnih materijala".',
url: 'https://i.imgur.com/okTpbHhm.jpg',
- alt: 'A pale wire-like sculpture mounted on concrete wall and descending on the floor. It appears light.'
+ alt: 'Bleda skulptura nalik na žicu postavljena na betonski zid spuštajući se na pod. Izgleda lako.'
}, {
name: 'Hippos',
artist: 'Taipei Zoo',
- description: 'The Taipei Zoo commissioned a Hippo Square featuring submerged hippos at play.',
+ description: 'Zoološki vrt u Tajpeju je naručio trg nilskih konja koji se igraju zaronjeni.',
url: 'https://i.imgur.com/6o5Vuyu.jpg',
- alt: 'A group of bronze hippo sculptures emerging from the sett sidewalk as if they were swimming.'
+ alt: 'Grupa bronzanih skulptura nilskih konja koji kao da isplivavaju na trotoar.'
}];
-// Make UI match the initial state.
+// Učini da UI prikazuje inicijalni state.
updateDOM();
```
```html public/index.html
@@ -724,15 +724,15 @@ button { display: block; margin-bottom: 10px; }
-You don't have to understand it to use React, but you might find this a helpful mental model.
+Ne morate ovo razumeti da bi koristili React, ali vam može koristiti kao mentalni model.
-## State is isolated and private {/*state-is-isolated-and-private*/}
+## State je izolovan i privatan {/*state-is-isolated-and-private*/}
-State is local to a component instance on the screen. In other words, **if you render the same component twice, each copy will have completely isolated state!** Changing one of them will not affect the other.
+State je lokalan za instancu komponente na ekranu. Drugim rečima, **ako jednu komponentu renderujete dvaput, svaka će imati potpuno izolovan state**! Promenom jednog nećete uticati na drugi.
-In this example, the `Gallery` component from earlier is rendered twice with no changes to its logic. Try clicking the buttons inside each of the galleries. Notice that their state is independent:
+U ovom primeru, `Gallery` komponenta od ranije je renderovana dvaput bez promena u njenoj logici. Probajte da kliknete dugmiće u svakoj galeriji. Primetite da su njihovi state-ovi nezavisni:
@@ -770,17 +770,17 @@ export default function Gallery() {
return (
{sculpture.name}
- by {sculpture.artist}
+ napravio/la {sculpture.artist}
- ({index + 1} of {sculptureList.length})
+ ({index + 1} od {sculptureList.length})
{showMore &&
{sculpture.description}
}
-This is what makes state different from regular variables that you might declare at the top of your module. State is not tied to a particular function call or a place in the code, but it's "local" to the specific place on the screen. You rendered two `` components, so their state is stored separately.
+Ovo je ono što state čini drugačijim od običnih promenljivih koje biste deklarisali na vrhu modula. State nije vezan za određeni poziv funkcije niti za mesto u kodu, već je "lokalan" za specifično mesto na ekranu. Renderovali ste dve `` komponente, pa im se state čuva odvojeno.
-Also notice how the `Page` component doesn't "know" anything about the `Gallery` state or even whether it has any. Unlike props, **state is fully private to the component declaring it.** The parent component can't change it. This lets you add state to any component or remove it without impacting the rest of the components.
+Primetite i da `Page` komponenta ne "zna" ništa o `Gallery` state-u niti da li on uopšte postoji. Za razliku od props-a, **state je potpuno privatan u komponenti koja ga deklariše**. Roditeljska komponenta ga ne može promeniti. Ovo vam omogućava da dodate ili uklonite state iz neke komponente bez uticaja na ostale komponente.
-What if you wanted both galleries to keep their states in sync? The right way to do it in React is to *remove* state from child components and add it to their closest shared parent. The next few pages will focus on organizing state of a single component, but we will return to this topic in [Sharing State Between Components.](/learn/sharing-state-between-components)
+Šta ako poželite da obe galerije sinhronizuju state? Pravilan način da to uradite u React-u je da *uklonite* state iz dečjih komponenata i dodate ga u najbližeg zajedničkog roditelja. Narednih nekoliko stranica će se fokusirati na organizaciju state-a u jednoj komponenti, ali vratićemo se na ovu temu u [Podela state-a među komponentama](/learn/sharing-state-between-components).
-* Use a state variable when a component needs to "remember" some information between renders.
-* State variables are declared by calling the `useState` Hook.
-* Hooks are special functions that start with `use`. They let you "hook into" React features like state.
-* Hooks might remind you of imports: they need to be called unconditionally. Calling Hooks, including `useState`, is only valid at the top level of a component or another Hook.
-* The `useState` Hook returns a pair of values: the current state and the function to update it.
-* You can have more than one state variable. Internally, React matches them up by their order.
-* State is private to the component. If you render it in two places, each copy gets its own state.
+* Koristite state promenljivu kada komponenta treba da "upamti" neke informacije između rendera.
+* State promenljive su deklarisane pozivanjem `useState` Hook-a.
+* Hook-ovi su specijalne funkcije koje počinju sa `use`. Omogućavaju vam da "se zakačite" za React funkcionalnosti poput state-a.
+* Hook-ovi mogu podsećati na import-e: moraju biti pozvani bezuslovno. Pozivanje Hook-ova, uključujući i `useState`, dozvoljeno je samo na početku komponenata ili drugog Hook-a.
+* `useState` Hook vraća par vrednosti: trenutni state i funkciju koja ga ažurira.
+* Možete imati više od jedne state promenljive. Interno, React ih prepoznaje po redosledu.
+* State je privatan za komponentu. Ako je renderujete na dva mesta, svaka će imati svoj state.
@@ -913,11 +913,11 @@ What if you wanted both galleries to keep their states in sync? The right way to
-#### Complete the gallery {/*complete-the-gallery*/}
+#### Kompletirati galeriju {/*complete-the-gallery*/}
-When you press "Next" on the last sculpture, the code crashes. Fix the logic to prevent the crash. You may do this by adding extra logic to event handler or by disabling the button when the action is not possible.
+Kada pritisnete "Naredno" na poslednjoj skulpturi, kod prestaje da radi. Popravite logiku da biste to sprečili. Možete ovo rešiti dodavanjem dodatne logike u event handler ili onemogućavanjem dugmeta kada akcija nije moguća.
-After fixing the crash, add a "Previous" button that shows the previous sculpture. It shouldn't crash on the first sculpture.
+Kada ovo popravite, dodajte dugme "Prethodno" koje prikazuje prethodnu skulpturu. Ne bi trebalo da se skrši na prvoj skulpturi.
@@ -941,17 +941,17 @@ export default function Gallery() {
return (
<>
{sculpture.name}
- by {sculpture.artist}
+ napravio/la {sculpture.artist}
- ({index + 1} of {sculptureList.length})
+ ({index + 1} od {sculptureList.length})
{showMore &&
{sculpture.description}
}
-This adds a guarding condition inside both event handlers and disables the buttons when needed:
+Ovo dodaje zaštitni uslov unutar oba event handler-a i onemogućava dugmiće kad je potrebno:
@@ -1097,23 +1097,23 @@ export default function Gallery() {
onClick={handlePrevClick}
disabled={!hasPrev}
>
- Previous
+ Prethodno
{sculpture.name}
- by {sculpture.artist}
+ napravio/la {sculpture.artist}
- ({index + 1} of {sculptureList.length})
+ ({index + 1} od {sculptureList.length})
{showMore &&
{sculpture.description}
}
-Notice how `hasPrev` and `hasNext` are used *both* for the returned JSX and inside the event handlers! This handy pattern works because event handler functions ["close over"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) any variables declared while rendering.
+Primetite da su `hasPrev` i `hasNext` korišćeni na *dva* mesta, u povratnom JSX-u i unutar event handler-a! Ovaj zgodni šablon radi zato što event handler funkcije ["zatvaraju"](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) sve promenljive deklarisane tokom renderovanja.
-#### Fix stuck form inputs {/*fix-stuck-form-inputs*/}
+#### Popraviti zaglavljene input-e forme {/*fix-stuck-form-inputs*/}
-When you type into the input fields, nothing appears. It's like the input values are "stuck" with empty strings. The `value` of the first `` is set to always match the `firstName` variable, and the `value` for the second `` is set to always match the `lastName` variable. This is correct. Both inputs have `onChange` event handlers, which try to update the variables based on the latest user input (`e.target.value`). However, the variables don't seem to "remember" their values between re-renders. Fix this by using state variables instead.
+Kada kucate u input polja, ništa se ne prikazuje. Kao da su input vrednosti "zaglavljene" sa praznim stringovima. `value` prvog ``-a je setovan da uvek odgovara `firstName` promenljivoj, a `value` drugog ``-a je setovan da uvek odgovara `lastName` promenljivoj. Ovo je tačno. Oba input-a imaju `onChange` event handler-e koji pokušavaju da ažuriraju promenljive na osnovu poslednje vrednosti koju je korisnik uneo (`e.target.value`). Međutim, deluje da promenljive ne "pamte" svoje vrednosti između rendera. Popravite ovo korišćenjem state promenljivih.
@@ -1250,17 +1250,17 @@ export default function Form() {
return (
);
}
@@ -1274,7 +1274,7 @@ h1 { margin-top: 10px; }
-First, import `useState` from React. Then replace `firstName` and `lastName` with state variables declared by calling `useState`. Finally, replace every `firstName = ...` assignment with `setFirstName(...)`, and do the same for `lastName`. Don't forget to update `handleReset` too so that the reset button works.
+Prvo, import-ujte `useState` iz React-a. Onda zamenite `firstName` i `lastName` sa state promenljivama deklarisanim pozivanjem `useState`. Na kraju, zamenite svaku `firstName = ...` dodelu sa `setFirstName(...)`, a onda uradite isto i za `lastName`. Ne zaboravite da promenite i `handleReset` kako bi dugme za resetovanje radilo.
@@ -1301,17 +1301,17 @@ export default function Form() {
return (
);
}
@@ -1325,13 +1325,13 @@ h1 { margin-top: 10px; }
-#### Fix a crash {/*fix-a-crash*/}
+#### Popraviti problem {/*fix-a-crash*/}
-Here is a small form that is supposed to let the user leave some feedback. When the feedback is submitted, it's supposed to display a thank-you message. However, it crashes with an error message saying "Rendered fewer hooks than expected". Can you spot the mistake and fix it?
+Ovde je mala forma koja treba služiti korisnicima da unesu feedback. Kada se feedback submit-uje, trebalo bi da se prikaže poruka zahvalnosti. Međutim, skrši se sa porukom o grešci koja kaže "Renderovano manje hook-ova nego što je očekivano" ("Rendered fewer hooks than expected"). Možete li uočiti grešku i popraviti je?
-Are there any limitations on _where_ Hooks may be called? Does this component break any rules? Check if there are any comments disabling the linter checks--this is where the bugs often hide!
+Postoje li ograničenja _gde_ se Hook-ovi mogu pozvati? Da li komponenta krši neka pravila? Proverite da li postoje neki komentari koji gase linter provere--to je mesto gde se bug-ovi često kriju!
@@ -1343,23 +1343,23 @@ import { useState } from 'react';
export default function FeedbackForm() {
const [isSent, setIsSent] = useState(false);
if (isSent) {
- return
Thank you!
;
+ return
Hvala!
;
} else {
// eslint-disable-next-line
const [message, setMessage] = useState('');
return (
);
}
@@ -1370,9 +1370,9 @@ export default function FeedbackForm() {
-Hooks can only be called at the top level of the component function. Here, the first `isSent` definition follows this rule, but the `message` definition is nested in a condition.
+Hook-ovi mogu biti pozvani samo na početku funkcije komponente. Ovde, prva `isSent` definicija poštuje to pravilo, ali `message` definicija je ugnježdena u uslov.
-Move it out of the condition to fix the issue:
+Pomerite je izvan uslova da biste popravili problem:
@@ -1384,21 +1384,21 @@ export default function FeedbackForm() {
const [message, setMessage] = useState('');
if (isSent) {
- return
Thank you!
;
+ return
Hvala!
;
} else {
return (
);
}
@@ -1407,9 +1407,9 @@ export default function FeedbackForm() {
-Remember, Hooks must be called unconditionally and always in the same order!
+Upamtite, Hook-ovi moraju biti pozvani bezuslovno i uvek u istom redosledu!
-You could also remove the unnecessary `else` branch to reduce the nesting. However, it's still important that all calls to Hooks happen *before* the first `return`.
+Takođe možete ukloniti nepotrebnu `else` granu da sprečite ugnježdavanje. Međutim, i dalje je bitno da se svi Hook-ovi pozovu *pre* prvog `return`-a.
@@ -1421,22 +1421,22 @@ export default function FeedbackForm() {
const [message, setMessage] = useState('');
if (isSent) {
- return
Thank you!
;
+ return
Hvala!
;
}
return (
);
}
@@ -1444,19 +1444,19 @@ export default function FeedbackForm() {
-Try moving the second `useState` call after the `if` condition and notice how this breaks it again.
+Pokušajte da pomerite drugi `useState` poziv nakon `if` uslova i vidite kako ponovo neće raditi.
-If your linter is [configured for React](/learn/editor-setup#linting), you should see a lint error when you make a mistake like this. If you don't see an error when you try the faulty code locally, you need to set up linting for your project.
+Ako je vaš linter [konfigurisan za React](/learn/editor-setup#linting), trebali biste videti lint grešku kad uradite ovako nešto. Ako ne vidite grešku kada napišete neispravan kod lokalno, potrebno je da postavite linting za vaš projekat.
-#### Remove unnecessary state {/*remove-unnecessary-state*/}
+#### Ukloniti nepotreban state {/*remove-unnecessary-state*/}
-When the button is clicked, this example should ask for the user's name and then display an alert greeting them. You tried to use state to keep the name, but for some reason it always shows "Hello, !".
+Kada se klikne dugme, ovaj primer treba pitati korisnika da unese ime, a onda da prikaže alert koji ga pozdravlja. Pokušali ste da koristite state da čuvate ime, ali iz nekog razloga uvek se prikazuje "Zdravo, !".
-To fix this code, remove the unnecessary state variable. (We will discuss about [why this didn't work](/learn/state-as-a-snapshot) later.)
+Da biste popravili kod, uklonite nepotrebnu state promenljivu. (Diskutovaćemo zašto [ovo nije radilo](/learn/state-as-a-snapshot) kasnije.)
-Can you explain why this state variable was unnecessary?
+Možete li objasniti zašto state promenljiva nije potrebna?
@@ -1467,13 +1467,13 @@ export default function FeedbackForm() {
const [name, setName] = useState('');
function handleClick() {
- setName(prompt('What is your name?'));
- alert(`Hello, ${name}!`);
+ setName(prompt('Koje je vaše ime?'));
+ alert(`Zdravo, ${name}!`);
}
return (
);
}
@@ -1483,20 +1483,20 @@ export default function FeedbackForm() {
-Here is a fixed version that uses a regular `name` variable declared in the function that needs it:
+Evo popravljene verzije koja koristi običnu `name` promenljivu deklarisanu u funkciji gde je potrebna:
```js
export default function FeedbackForm() {
function handleClick() {
- const name = prompt('What is your name?');
- alert(`Hello, ${name}!`);
+ const name = prompt('Koje je vaše ime?');
+ alert(`Zdravo, ${name}!`);
}
return (
);
}
@@ -1504,7 +1504,7 @@ export default function FeedbackForm() {
-A state variable is only necessary to keep information between re-renders of a component. Within a single event handler, a regular variable will do fine. Don't introduce state variables when a regular variable works well.
+State promenljiva je neophodna samo za čuvanje informacija između ponovnih rendera u komponenti. Unutar jednog event handler-a, obična promenljiva radi posao. Nemojte koristiti state promenljive kada i obične promenljive rade.