diff --git a/src/content/learn/describing-the-ui.md b/src/content/learn/describing-the-ui.md
index b41200b5..21608f70 100644
--- a/src/content/learn/describing-the-ui.md
+++ b/src/content/learn/describing-the-ui.md
@@ -525,16 +525,16 @@ Pročitajte **[Održavanje komponenata čistim](/learn/keeping-components-pure)*
-## Razumevanje vašeg UI kao stabla {/*understanding-your-ui-as-a-tree*/}
+## Razumevanje vašeg UI-a kao stabla {/*understanding-your-ui-as-a-tree*/}
React koristi stabla da modeluje odnose između komponenata i modula.
-React render stablo je reprezentacija odnosa roditelj-dete između komponenata.
+React stablo renderovanja je reprezentacija odnosa roditelj-dete između komponenata.
-Primer render stabla.
+Primer stabla renderovanja.
diff --git a/src/content/learn/managing-state.md b/src/content/learn/managing-state.md
index 555bf922..83c0f9b7 100644
--- a/src/content/learn/managing-state.md
+++ b/src/content/learn/managing-state.md
@@ -399,7 +399,7 @@ textarea {
-React vam omogućava da override-ujete default ponašanje i *forsirate* komponentu da resetuje svoje stanje prosleđivanjem različitog `key`-a, na primer ``. Ovo govori React-u da ako je primalac drugačiji, treba da smatra da se *drugačija* `Chat` komponenta treba ponovo kreirati od nule sa novim podacima (i UI-jem poput input-a). Sada, promena primaoca resetuje polje za input--iako renderujete istu komponentu.
+React vam omogućava da override-ujete default ponašanje i *forsirate* komponentu da resetuje svoj state prosleđivanjem različitog `key`-a, na primer ``. Ovo govori React-u da ako je primalac drugačiji, treba da smatra da se *drugačija* `Chat` komponenta treba ponovo kreirati od nule sa novim podacima (i UI-jem poput input-a). Sada, promena primaoca resetuje polje za input--iako renderujete istu komponentu.
diff --git a/src/content/learn/preserving-and-resetting-state.md b/src/content/learn/preserving-and-resetting-state.md
index 11d398d2..0b908d34 100644
--- a/src/content/learn/preserving-and-resetting-state.md
+++ b/src/content/learn/preserving-and-resetting-state.md
@@ -1,28 +1,28 @@
---
-title: Preserving and Resetting State
+title: Čuvanje i resetovanje state-a
---
-State is isolated between components. React keeps track of which state belongs to which component based on their place in the UI tree. You can control when to preserve state and when to reset it between re-renders.
+State je izolovan između komponenata. React prati koji state pripada kojoj komponenti na osnovu njenog mesta u UI stablu. Možete kontrolisati kada čuvati state, a kada ga resetovati između ponovnih rendera.
-* When React chooses to preserve or reset the state
-* How to force React to reset component's state
-* How keys and types affect whether the state is preserved
+* Kada React bira da li da čuva ili resetuje state
+* Kako naterati React da resetuje state komponente
+* Kako ključevi i tipovi utiču na to da li je state sačuvan
-## State is tied to a position in the render tree {/*state-is-tied-to-a-position-in-the-tree*/}
+## State je povezan sa pozicijom u stablu renderovanja {/*state-is-tied-to-a-position-in-the-tree*/}
-React builds [render trees](learn/understanding-your-ui-as-a-tree#the-render-tree) for the component structure in your UI.
+React pravi [stabla renderovanja](learn/understanding-your-ui-as-a-tree#the-render-tree) za strukturu komponenti na vašem UI-u.
-When you give a component state, you might think the state "lives" inside the component. But the state is actually held inside React. React associates each piece of state it's holding with the correct component by where that component sits in the render tree.
+Kada komponenti date state, možete pomisliti da state "živi" unutar komponente. Ali, state se zapravo čuva unutar React-a. React povezuje svaki deo state-a sa tačnom komponentom na osnovu mesta na kom se ta komponenta nalazi u stablu renderovanja.
-Here, there is only one `` JSX tag, but it's rendered at two different positions:
+Ovde postoji samo jedan `` JSX tag, ali je renderovan na dve različite pozicije:
@@ -56,7 +56,7 @@ function Counter() {
>
{score}
);
@@ -86,23 +86,23 @@ label {
-Here's how these look as a tree:
+Evo kako to izgleda u obliku stabla:
-
+
-React tree
+React stablo
-**These are two separate counters because each is rendered at its own position in the tree.** You don't usually have to think about these positions to use React, but it can be useful to understand how it works.
+**Ovo su dva odvojena brojača jer je svaki renderovan na svojoj poziciji u stablu.** Obično ne morate razmišljati o ovim pozicijama da biste koristili React, ali može biti korisno da razumete kako to funkcioniše.
-In React, each component on the screen has fully isolated state. For example, if you render two `Counter` components side by side, each of them will get its own, independent, `score` and `hover` states.
+U React-u, svaka komponenta na ekranu ima potpuno izolovan state. Na primer, ako renderujete dve `Counter` komponente jednu pored druge, svaka će imati svoje nezavisne `score` i `hover` state-ove.
-Try clicking both counters and notice they don't affect each other:
+Probajte da kliknete oba brojača i primetite da ne utiču jedan na drugog:
@@ -135,7 +135,7 @@ function Counter() {
>
{score}
);
@@ -160,21 +160,21 @@ function Counter() {
-As you can see, when one counter is updated, only the state for that component is updated:
+Kao što možete videti, kada je jedan brojač ažuriran, jedino se state za tu komponentu ažurira:
-
+
-Updating state
+Ažuriranje state-a
-React will keep the state around for as long as you render the same component at the same position in the tree. To see this, increment both counters, then remove the second component by unchecking "Render the second counter" checkbox, and then add it back by ticking it again:
+React će držati state dok god istu komponentu renderujete na istoj poziciji u stablu. Da biste ovo primetili, inkrementirajte oba brojača, uklonite drugu komponentu tako što ćete odštiklirati checkbox "Renderuj drugi brojač", a onda je štikliranjem dodajte ponovo:
@@ -195,7 +195,7 @@ export default function App() {
setShowB(e.target.checked)
}}
/>
- Render the second counter
+ Renderuj drugi brojač
);
@@ -218,7 +218,7 @@ function Counter() {
>
{score}
);
@@ -248,35 +248,35 @@ label {
-Notice how the moment you stop rendering the second counter, its state disappears completely. That's because when React removes a component, it destroys its state.
+Primetite da u trenutku kada prestanete da renderujete drugi brojač, njegov state potpuno nestaje. To je zato što kad React ukloni komponentu, uklanja i njen state.
-
+
-Deleting a component
+Brisanje komponente
-When you tick "Render the second counter", a second `Counter` and its state are initialized from scratch (`score = 0`) and added to the DOM.
+Kada štiklirate "Renderuj drugi brojač", drugi `Counter` i njegov state se inicijalizuju od nule (`score = 0`) i dodaju u DOM.
-
+
-Adding a component
+Dodavanje komponente
-**React preserves a component's state for as long as it's being rendered at its position in the UI tree.** If it gets removed, or a different component gets rendered at the same position, React discards its state.
+**React čuva state komponente dok god se renderuje na svojoj poziciji u UI stablu.** Ako se ukloni, ili se druga komponenta renderuje na istoj poziciji, React odbacuje njen state.
-## Same component at the same position preserves state {/*same-component-at-the-same-position-preserves-state*/}
+## Ista komponenta na istoj poziciji čuva state {/*same-component-at-the-same-position-preserves-state*/}
-In this example, there are two different `` tags:
+U ovom primeru postoje dva različita `` tag-a:
@@ -300,7 +300,7 @@ export default function App() {
setIsFancy(e.target.checked)
}}
/>
- Use fancy styling
+ Koristi fensi stajling
);
@@ -326,7 +326,7 @@ function Counter({ isFancy }) {
>
{score}
);
@@ -361,24 +361,24 @@ label {
-When you tick or clear the checkbox, the counter state does not get reset. Whether `isFancy` is `true` or `false`, you always have a `` as the first child of the `div` returned from the root `App` component:
+Kada promenite checkbox, counter state ne bude resetovan. Nezavisno od toga da li je `isFancy` jednak `true` ili `false`, uvek ćete imati `` kao prvo dete `div`-a koje je vraćeno iz korenske `App` komponente:
-
+
-Updating the `App` state does not reset the `Counter` because `Counter` stays in the same position
+Ažuriranje `App` state-a ne resetuje `Counter` zato što `Counter` ostaje na istoj poziciji
-It's the same component at the same position, so from React's perspective, it's the same counter.
+To je ista komponenta na istoj poziciji, pa je iz React perspektive to isti brojač.
-Remember that **it's the position in the UI tree--not in the JSX markup--that matters to React!** This component has two `return` clauses with different `` JSX tags inside and outside the `if`:
+Zapamtite da je **pozicija u UI stablu--ne u JSX markup-u--ono što je React-u bitno**! Ova komponenta ima dva `return` iskaza sa različitim `` JSX tag-ovima unutar i izvan `if`-a:
@@ -399,7 +399,7 @@ export default function App() {
setIsFancy(e.target.checked)
}}
/>
- Use fancy styling
+ Koristi fensi stajling
);
@@ -415,7 +415,7 @@ export default function App() {
setIsFancy(e.target.checked)
}}
/>
- Use fancy styling
+ Koristi fensi stajling
);
@@ -441,7 +441,7 @@ function Counter({ isFancy }) {
>
{score}
);
@@ -476,15 +476,15 @@ label {
-You might expect the state to reset when you tick checkbox, but it doesn't! This is because **both of these `` tags are rendered at the same position.** React doesn't know where you place the conditions in your function. All it "sees" is the tree you return.
+Možda biste očekivali da se state resetuje kada promenite checkbox, ali to nije slučaj! To se dešava jer su **oba `` tag-a renderovana na istoj poziciji**. React ne zna gde vi pravite uslove u vašoj funkciji. Sve što "vidi" je stablo koje vratite.
-In both cases, the `App` component returns a `
` with `` as a first child. To React, these two counters have the same "address": the first child of the first child of the root. This is how React matches them up between the previous and next renders, regardless of how you structure your logic.
+U oba slučaja, `App` komponenta vraća `
` sa `` kao prvim detetom. Za React, ova dva brojača imaju iste "adrese": prvo dete prvog deteta od korena. Ovako ih React poredi između prethodnih i narednih rendera, nezavisno od strukture vaše logike.
-## Different components at the same position reset state {/*different-components-at-the-same-position-reset-state*/}
+## Različite komponente na istoj poziciji resetuju state {/*different-components-at-the-same-position-reset-state*/}
-In this example, ticking the checkbox will replace `` with a `
`:
+U ovom primeru, štikliranje checkbox-a će zameniti `` sa `
) : (
)}
@@ -508,7 +508,7 @@ export default function App() {
setIsPaused(e.target.checked)
}}
/>
- Take a break
+ Uzmi pauzu
);
@@ -531,7 +531,7 @@ function Counter() {
>
{score}
);
@@ -561,13 +561,13 @@ label {
-Here, you switch between _different_ component types at the same position. Initially, the first child of the `
` contained a `Counter`. But when you swapped in a `p`, React removed the `Counter` from the UI tree and destroyed its state.
+Ovde menjate između _različitih_ tipova komponenti na istoj poziciji. Inicijalno, prvo dete `
`-a je bio `Counter`. Ali kad ste ga zamenili sa `p`, React je uklonio `Counter` iz UI stabla i uništio njegov state.
-
+
-When `Counter` changes to `p`, the `Counter` is deleted and the `p` is added
+Kada se `Counter` zameni sa `p`, `Counter` je obrisan i `p` je dodat
@@ -575,15 +575,15 @@ When `Counter` changes to `p`, the `Counter` is deleted and the `p` is added
-
+
-When switching back, the `p` is deleted and the `Counter` is added
+Kada se ponovo promene, `p` je obrisan, a `Counter` je dodat
-Also, **when you render a different component in the same position, it resets the state of its entire subtree.** To see how this works, increment the counter and then tick the checkbox:
+Takođe, **kada renderujete različitu komponentu na istoj poziciji, resetuje se state od čitavog podstabla**. Da vidite kako ovo radi, inkrementirajte brojač i onda štiklirajte checkbox:
@@ -611,7 +611,7 @@ export default function App() {
setIsFancy(e.target.checked)
}}
/>
- Use fancy styling
+ Koristi fensi stajling
);
@@ -672,13 +672,13 @@ label {
-The counter state gets reset when you click the checkbox. Although you render a `Counter`, the first child of the `div` changes from a `section` to a `div`. When the child `section` was removed from the DOM, the whole tree below it (including the `Counter` and its state) was destroyed as well.
+State `Counter`-a se resetuje kada kliknete na checkbox. Iako renderujete `Counter`, prvo dete `div`-a se promeni sa `section` na `div`. Kada je dečji `section` uklonjen iz DOM-a, celokupno stablo ispod (uključujući `Counter` i njegov state) je takođe uništeno.
-
+
-When `section` changes to `div`, the `section` is deleted and the new `div` is added
+Kada se `section` promeni u `div`, `section` je obrisan, a novi `div` je dodat
@@ -686,21 +686,21 @@ When `section` changes to `div`, the `section` is deleted and the new `div` is a
-
+
-When switching back, the `div` is deleted and the new `section` is added
+Kada se ponovo promene, `div` je obrisan, a novi `section` je dodat
-As a rule of thumb, **if you want to preserve the state between re-renders, the structure of your tree needs to "match up"** from one render to another. If the structure is different, the state gets destroyed because React destroys state when it removes a component from the tree.
+Kao pravilo, **ako želite da sačuvate state između ponovnih rendera, struktura vašeg stabla mora da se "poklapa"** od jednog do drugog rendera. Ako je struktura različita, state će biti uništen jer React uništava state kada uklanja komponentu iz stabla.
-This is why you should not nest component function definitions.
+Zbog ovoga ne biste trebali da ugnježdavate definicije funkcija komponenti.
-Here, the `MyTextField` component function is defined *inside* `MyComponent`:
+Ovde je funkcija `MyTextField` komponente definisana *unutar* `MyComponent`:
@@ -726,7 +726,7 @@ export default function MyComponent() {
+ }}>Kliknuto {counter} puta
>
);
}
@@ -735,13 +735,13 @@ export default function MyComponent() {
-Every time you click the button, the input state disappears! This is because a *different* `MyTextField` function is created for every render of `MyComponent`. You're rendering a *different* component in the same position, so React resets all state below. This leads to bugs and performance problems. To avoid this problem, **always declare component functions at the top level, and don't nest their definitions.**
+Svaki put kad kliknete dugme, input state nestane! To se dešava jer je *različita* `MyTextField` funkcija kreirana za svaki render `MyComponent`-a. Renderujete *različitu* komponentu na istoj poziciji, pa React resetuje sve state-ove ispod. Ovo prouzrokuje bug-ove i probleme sa performansama. Da biste izbegli ovaj problem, **uvek deklarišite funkcije komponenti na najvišem nivou i nemojte ugnježdavati njihove definicije**.
-## Resetting state at the same position {/*resetting-state-at-the-same-position*/}
+## Resetovanje state-a na istoj poziciji {/*resetting-state-at-the-same-position*/}
-By default, React preserves state of a component while it stays at the same position. Usually, this is exactly what you want, so it makes sense as the default behavior. But sometimes, you may want to reset a component's state. Consider this app that lets two players keep track of their scores during each turn:
+Po default-u, React čuva state komponente dok god ostaje na istoj poziciji. Uglavnom je to upravo ono što želite, pa ima smisla da je to default ponašanje. Ali, ponekad možete želeti da resetujete state komponente. Razmotrite ovu aplikaciju koja omogućava dvojici igrača da prate svoje poene tokom svakog poteza:
@@ -760,7 +760,7 @@ export default function Scoreboard() {
);
@@ -781,9 +781,9 @@ function Counter({ person }) {
onPointerEnter={() => setHover(true)}
onPointerLeave={() => setHover(false)}
>
-
{person}'s score: {score}
+
Poeni za osobu {person}: {score}
);
@@ -811,19 +811,19 @@ h1 {
-Currently, when you change the player, the score is preserved. The two `Counter`s appear in the same position, so React sees them as *the same* `Counter` whose `person` prop has changed.
+Trenutno, kada promenite igrača, poeni ostaju sačuvani. Dve `Counter` komponente se nalaze na istoj poziciji, pa ih React posmatra kao *isti* `Counter` čiji se `person` prop promenio.
-But conceptually, in this app they should be two separate counters. They might appear in the same place in the UI, but one is a counter for Taylor, and another is a counter for Sarah.
+Ali konceptualno, u ovoj aplikaciji to trebaju biti dva odvojena brojača. Iako se pojavljuju na istom mestu na UI-u, jedan brojač je za Taylor, a drugi za Sarah.
-There are two ways to reset state when switching between them:
+Postoje dva načina da resetujete state kada ih menjate:
-1. Render components in different positions
-2. Give each component an explicit identity with `key`
+1. Renderujte komponente na različitim pozicijama
+2. Dajte svakoj komponenti eksplicitni identitet sa `key`
-### Option 1: Rendering a component in different positions {/*option-1-rendering-a-component-in-different-positions*/}
+### Opcija 1: Renderovanje komponente na različitim pozicijama {/*option-1-rendering-a-component-in-different-positions*/}
-If you want these two `Counter`s to be independent, you can render them in two different positions:
+Ako želite da ova dva `Counter`-a budu nezavisna, možete ih renderovati na dve različite pozicije:
@@ -843,7 +843,7 @@ export default function Scoreboard() {
);
@@ -864,9 +864,9 @@ function Counter({ person }) {
onPointerEnter={() => setHover(true)}
onPointerLeave={() => setHover(false)}
>
-
{person}'s score: {score}
+
Poeni za osobu {person}: {score}
);
@@ -894,42 +894,42 @@ h1 {
-* Initially, `isPlayerA` is `true`. So the first position contains `Counter` state, and the second one is empty.
-* When you click the "Next player" button the first position clears but the second one now contains a `Counter`.
+* Inicijalno, `isPlayerA` je `true`. To znači da prva pozicija sadrži `Counter` state, a druga je prazna.
+* Kada kliknete dugme "Naredni igrač" prva pozicija se briše, a druga sada sadrži `Counter`.
-
+
-Initial state
+Inicijalni state
-
+
-Clicking "next"
+Kliknuto "naredno"
-
+
-Clicking "next" again
+Kliknuto "naredno" opet
-Each `Counter`'s state gets destroyed each time it's removed from the DOM. This is why they reset every time you click the button.
+State svakog `Counter`-a bude uništen svaki put kad je uklonjen iz DOM-a. Zbog toga se resetuju svaki put kada kliknete dugme.
-This solution is convenient when you only have a few independent components rendered in the same place. In this example, you only have two, so it's not a hassle to render both separately in the JSX.
+Ovo rešenje je zgodno kada imate samo par komponenti renderovanih na istom mestu. U ovom primeru, imate ih samo dve, pa nije problem renderovati ih u različitom JSX-u.
-### Option 2: Resetting state with a key {/*option-2-resetting-state-with-a-key*/}
+### Opcija 2: Resetovanje state-a uz key {/*option-2-resetting-state-with-a-key*/}
-There is also another, more generic, way to reset a component's state.
+Postoji i drugi, više generički, način da resetujete state komponente.
-You might have seen `key`s when [rendering lists.](/learn/rendering-lists#keeping-list-items-in-order-with-key) Keys aren't just for lists! You can use keys to make React distinguish between any components. By default, React uses order within the parent ("first counter", "second counter") to discern between components. But keys let you tell React that this is not just a *first* counter, or a *second* counter, but a specific counter--for example, *Taylor's* counter. This way, React will know *Taylor's* counter wherever it appears in the tree!
+Možda ste videli `key`-eve tokom [renderovanja listi](/learn/rendering-lists#keeping-list-items-in-order-with-key). Ključevi nisu samo za liste! Možete koristiti ključeve da naterate React da razlikuje bilo koje komponente. Po default-u, React koristi redosled unutar roditelja ("prvi brojač", "drugi brojač") da razlikuje komponente. Ali, ključevi vam omogućavaju da kažete React-u da to nije samo *prvi* brojač, ili *drugi* brojač, već poseban brojač--na primer, *Taylor-ov* brojač. Na ovaj način, React će znati za *Taylor-ov* brojač gde god da se pojavi u stablu!
-In this example, the two ``s don't share state even though they appear in the same place in JSX:
+U ovom primeru, dva ``-a ne dele state iako se nalaze na istom mestu u JSX-u:
@@ -948,7 +948,7 @@ export default function Scoreboard() {
);
@@ -969,9 +969,9 @@ function Counter({ person }) {
onPointerEnter={() => setHover(true)}
onPointerLeave={() => setHover(false)}
>
-
{person}'s score: {score}
+
Poeni za osobu {person}: {score}
);
@@ -999,7 +999,7 @@ h1 {
-Switching between Taylor and Sarah does not preserve the state. This is because **you gave them different `key`s:**
+Menjanje između Taylor i Sarah ne čuva state. To je zato što ste **im dali različite `key`-eve:**
```js
{isPlayerA ? (
@@ -1009,19 +1009,19 @@ Switching between Taylor and Sarah does not preserve the state. This is because
)}
```
-Specifying a `key` tells React to use the `key` itself as part of the position, instead of their order within the parent. This is why, even though you render them in the same place in JSX, React sees them as two different counters, and so they will never share state. Every time a counter appears on the screen, its state is created. Every time it is removed, its state is destroyed. Toggling between them resets their state over and over.
+Specificiranje `key`-a govori React-u da koristi `key` kao deo pozicije umesto rasporeda unutar roditelja. Zbog toga, iako ih renderujete na istom mestu u JSX-u, React ih vidi kao dva različita brojača, tako da nikad neće deliti state. Svaki put kad se brojač pojavi na ekranu, njegov state je kreiran. Svaki put kad je uklonjen, njegov state je uništen. Promena između njih resetuje njihov state iznova.
-Remember that keys are not globally unique. They only specify the position *within the parent*.
+Zapamtite da ključevi nisu jedinstveni globalno. Oni samo označavaju poziciju *unutar roditelja*.
-### Resetting a form with a key {/*resetting-a-form-with-a-key*/}
+### Resetovanje forme sa key-em {/*resetting-a-form-with-a-key*/}
-Resetting state with a key is particularly useful when dealing with forms.
+Resetovanje state-a uz key je posebno korisno kada radite sa formama.
-In this chat app, the `` component contains the text input state:
+U ovoj aplikaciji za poruke, `` komponenta sadrži state za tekstualni input:
@@ -1084,11 +1084,11 @@ export default function Chat({ contact }) {
);
}
@@ -1116,17 +1116,17 @@ textarea {
-Try entering something into the input, and then press "Alice" or "Bob" to choose a different recipient. You will notice that the input state is preserved because the `` is rendered at the same position in the tree.
+Pokušajte da unesete nešto u input, a onda pritisnite "Alice" ili "Bob" da odaberete drugog primaoca. Primetićete da je input state sačuvan zato što je `` renderovan na istoj poziciji u stablu.
-**In many apps, this may be the desired behavior, but not in a chat app!** You don't want to let the user send a message they already typed to a wrong person due to an accidental click. To fix it, add a `key`:
+**U mnogim aplikacijama ovo može biti željeno ponašanje, ali ne i u aplikaciji za poruke!** Ne želite da dopustite korisniku da pošalje već otkucanu poruku pogrešnoj osobi zbog slučajnog klika. Da biste ovo popravili, dodajte `key`:
```js
```
-This ensures that when you select a different recipient, the `Chat` component will be recreated from scratch, including any state in the tree below it. React will also re-create the DOM elements instead of reusing them.
+Ovo osigurava da kada odaberete drugog primaoca, da će `Chat` komponenta biti napravljena od nule, uključujući bilo koji state u stablu ispod. React će takođe ponovo kreirati DOM elemente umesto da ih ponovo iskoristi.
-Now switching the recipient always clears the text field:
+Sada promena primaoca uvek briše tekstualno polje:
@@ -1189,11 +1189,11 @@ export default function Chat({ contact }) {
);
}
@@ -1223,24 +1223,24 @@ textarea {
-#### Preserving state for removed components {/*preserving-state-for-removed-components*/}
+#### Čuvanje state-a za uklonjene komponente {/*preserving-state-for-removed-components*/}
-In a real chat app, you'd probably want to recover the input state when the user selects the previous recipient again. There are a few ways to keep the state "alive" for a component that's no longer visible:
+U pravoj aplikaciji za poruke, verovatno ćete želeti da povratite input state kada korisnik izabere prethodnog primaoca ponovo. Postoji par načina da držite state "živim" za komponentu koja nije više vidljiva:
-- You could render _all_ chats instead of just the current one, but hide all the others with CSS. The chats would not get removed from the tree, so their local state would be preserved. This solution works great for simple UIs. But it can get very slow if the hidden trees are large and contain a lot of DOM nodes.
-- You could [lift the state up](/learn/sharing-state-between-components) and hold the pending message for each recipient in the parent component. This way, when the child components get removed, it doesn't matter, because it's the parent that keeps the important information. This is the most common solution.
-- You might also use a different source in addition to React state. For example, you probably want a message draft to persist even if the user accidentally closes the page. To implement this, you could have the `Chat` component initialize its state by reading from the [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), and save the drafts there too.
+- Mogli biste da renderujete _sve_ chat-ove umesto samo jednog, ali da ostale sakrijete pomoću CSS-a. Chat-ovi neće biti uklonjeni iz stabla, pa će njihov lokalni state biti sačuvan. Ovo rešenje radi dobro za jednostavne UI-e. Ali, može postati dosta sporo ako su skrivena stabla velika i sadrže mnogo DOM čvorova.
+- Mogli biste [podići state](/learn/sharing-state-between-components) i čuvati poruke na čekanju za svakog primaoca u roditeljskoj komponenti. Na ovaj način, nije bitno ako dečje komponente budu uklonjene, jer njihov roditelj čuva bitne informacije. Ovo je najčešće rešenje.
+- Takođe možete koristiti i druge izvore informacija, kao ispomoć React state-u. Na primer, verovatno želite da sačuvate draft poruku čak iako korisnik slučajno zatvori stranicu. Da biste to implementirali, mogli biste napraviti da `Chat` komponenta inicijalizuje svoj state čitanjem iz [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage)-a, a takođe i da čuva draft poruke tamo.
-No matter which strategy you pick, a chat _with Alice_ is conceptually distinct from a chat _with Bob_, so it makes sense to give a `key` to the `` tree based on the current recipient.
+Nevezano za to koju strategiju odaberete, chat _sa Alice_ je konceptualno drugačiji od chat-a _sa Bob-om_, tako da ima smisla zadati `key` u `` stablo na osnovu trenutnog primaoca.
-- React keeps state for as long as the same component is rendered at the same position.
-- State is not kept in JSX tags. It's associated with the tree position in which you put that JSX.
-- You can force a subtree to reset its state by giving it a different key.
-- Don't nest component definitions, or you'll reset state by accident.
+- React čuva state dok god se ista komponenta renderuje na istoj poziciji.
+- State se ne čuva u JSX tag-ovima. Povezan je sa pozicijom u stablu na koju stavljate taj JSX.
+- Možete forsirati podstablo da resetuje svoj state tako što ćete mu dati drugačiji key.
+- Nemojte ugnježdavati definicije komponenti, ili ćete slučajno resetovati state.
@@ -1248,9 +1248,9 @@ No matter which strategy you pick, a chat _with Alice_ is conceptually distinct
-#### Fix disappearing input text {/*fix-disappearing-input-text*/}
+#### Popraviti nestajući tekst u input-u {/*fix-disappearing-input-text*/}
-This example shows a message when you press the button. However, pressing the button also accidentally resets the input. Why does this happen? Fix it so that pressing the button does not reset the input text.
+Ovaj primer prikazuje poruku kada kliknete dugme. Međutim, klik na dugme slučajno resetuje input. Zašto se ovo dešava? Popravite to tako da klik na dugme ne resetuje tekst u input-u.
@@ -1262,11 +1262,11 @@ export default function App() {
if (showHint) {
return (
-
Hint: Your favorite city?
+
Pomoć: Vaš omiljeni grad?
+ }}>Sakrij pomoć
);
}
@@ -1275,7 +1275,7 @@ export default function App() {
+ }}>Prikaži pomoć
);
}
@@ -1299,9 +1299,9 @@ textarea { display: block; margin: 10px 0; }
-The problem is that `Form` is rendered in different positions. In the `if` branch, it is the second child of the `
`, but in the `else` branch, it is the first child. Therefore, the component type in each position changes. The first position changes between holding a `p` and a `Form`, while the second position changes between holding a `Form` and a `button`. React resets the state every time the component type changes.
+Problem je u tome što je `Form` renderovan na različitim pozicijama. U `if` grani, to je drugo dete od `
`-a, ali je u `else` grani prvo dete. Zbog toga se tip komponente na svakoj poziciji menja. Na prvoj poziciji se menjaju `p` i `Form`, dok se na drugoj poziciji menjaju `Form` i `button`. React resetuje state svaki put kada se tip komponente promeni.
-The easiest solution is to unify the branches so that `Form` always renders in the same position:
+Najlakše rešenje je da objedinite te dve grane da uvek renderuju `Form` na istoj poziciji:
@@ -1313,17 +1313,17 @@ export default function App() {
return (
{showHint &&
-
Hint: Your favorite city?
+
Pomoć: Vaš omiljeni grad?
}
{showHint ? (
+ }}>Sakrij pomoć
) : (
+ }}>Prikaži pomoć
)}
);
@@ -1347,7 +1347,7 @@ textarea { display: block; margin: 10px 0; }
-Technically, you could also add `null` before `` in the `else` branch to match the `if` branch structure:
+Tehnički, mogli biste takođe dodati `null` pre `` u `else` grani kako bi se poklapala sa strukturom `if` grane:
@@ -1359,11 +1359,11 @@ export default function App() {
if (showHint) {
return (
-
Hint: Your favorite city?
+
Pomoć: Vaš omiljeni grad?
+ }}>Sakrij pomoć
);
}
@@ -1373,7 +1373,7 @@ export default function App() {
+ }}>Prikaži pomoć
);
}
@@ -1395,19 +1395,19 @@ textarea { display: block; margin: 10px 0; }
-This way, `Form` is always the second child, so it stays in the same position and keeps its state. But this approach is much less obvious and introduces a risk that someone else will remove that `null`.
+Na ovaj način, `Form` je uvek drugo dete, pa će ostati na istoj poziciji i sačuvati svoj state. Ali, ovaj pristup je mnogo manje očigledan i uvodi rizik da će neko ukloniti taj `null`.
-#### Swap two form fields {/*swap-two-form-fields*/}
+#### Zameniti dva polja u formi {/*swap-two-form-fields*/}
-This form lets you enter first and last name. It also has a checkbox controlling which field goes first. When you tick the checkbox, the "Last name" field will appear before the "First name" field.
+Ova forma vam omogućava da unesete ime i prezime. Takođe ima i checkbox koji kontroliše koje polje je prvo. Kada štiklirate checkbox, polje "Prezime" će se pojaviti pre polja "Ime".
-It almost works, but there is a bug. If you fill in the "First name" input and tick the checkbox, the text will stay in the first input (which is now "Last name"). Fix it so that the input text *also* moves when you reverse the order.
+Zamalo da radi, ali postoji bug. Ako popunite input "Ime" i štiklirate checkbox, tekst će ostati u prvom input-u (što je sada "Prezime"). Popravite ovo tako da se input tekst *takođe* pomera kada obrnete redosled.
-It seems like for these fields, their position within the parent is not enough. Is there some way to tell React how to match up the state between re-renders?
+Deluje da za ova polja nije dovoljna njihova pozicija unutar roditelja. Postoji li način da kažete React-u kako da poklopi state između ponovnih rendera?
@@ -1425,22 +1425,22 @@ export default function App() {
checked={reverse}
onChange={e => setReverse(e.target.checked)}
/>
- Reverse order
+ Obrni redosled
);
if (reverse) {
return (
<>
-
-
+
+
{checkbox}
>
);
} else {
return (
<>
-
-
+
+
{checkbox}
>
);
@@ -1471,7 +1471,7 @@ label { display: block; margin: 10px 0; }
-Give a `key` to both `` components in both `if` and `else` branches. This tells React how to "match up" the correct state for either `` even if their order within the parent changes:
+Dodelite `key` u obe `` komponente i u `if` i u `else` granu. Ovo govori React-u kako da "poklopi" ispravan state za svaki `` čak iako se njihov redosled unutar roditelja promeni:
@@ -1487,22 +1487,22 @@ export default function App() {
checked={reverse}
onChange={e => setReverse(e.target.checked)}
/>
- Reverse order
+ Obrni redosled
);
if (reverse) {
return (
<>
-
-
+
+
{checkbox}
>
);
} else {
return (
<>
-
-
+
+
{checkbox}
>
);
@@ -1533,11 +1533,11 @@ label { display: block; margin: 10px 0; }
-#### Reset a detail form {/*reset-a-detail-form*/}
+#### Resetovati formu sa detaljima {/*reset-a-detail-form*/}
-This is an editable contact list. You can edit the selected contact's details and then either press "Save" to update it, or "Reset" to undo your changes.
+Ovo je lista kontakata koja može da se menja. Možete menjati detalje odabranog kontakta i onda kliknuti "Sačuvaj" da ga ažurirate ili "Resetuj" da ukinete promene.
-When you select a different contact (for example, Alice), the state updates but the form keeps showing the previous contact's details. Fix it so that the form gets reset when the selected contact changes.
+Kada izaberete drugi kontakt (na primer, Alice), state se ažurira ali forma i dalje prikazuje detalje prethodnog kontakta. Popravite ovo tako da se forma resetuje kada se odabrani kontakt promeni.
@@ -1629,7 +1629,7 @@ export default function EditContact({ initialData, onSave }) {
return (
);
@@ -1689,7 +1689,7 @@ button {
-Give `key={selectedId}` to the `EditContact` component. This way, switching between different contacts will reset the form:
+Dodelite `key={selectedId}` u `EditContact` komponentu. Na ovaj način, promena kontakata će resetovati formu:
@@ -1782,7 +1782,7 @@ export default function EditContact({ initialData, onSave }) {
return (
);
@@ -1842,13 +1842,13 @@ button {
-#### Clear an image while it's loading {/*clear-an-image-while-its-loading*/}
+#### Ukloniti sliku dok se učitava {/*clear-an-image-while-its-loading*/}
-When you press "Next", the browser starts loading the next image. However, because it's displayed in the same `` tag, by default you would still see the previous image until the next one loads. This may be undesirable if it's important for the text to always match the image. Change it so that the moment you press "Next", the previous image immediately clears.
+Kada kliknete "Naredno", pretraživač počinje da učitava narednu sliku. Međutim, pošto je prikazana u istom `` tag-u, po default-u ćete i dalje videti prethodnu sliku dok se naredna ne učita. Ovo može biti neželjeno ako je bitno da se tekst uvek poklapa sa slikom. Promenite tako da u trenutku kada kliknete "Naredno", prethodna slika bude odmah uklonjena.
-Is there a way to tell React to re-create the DOM instead of reusing it?
+Postoji li način da kažete React-a da ponovo kreira DOM umesto da ga ponovo iskoristi?
@@ -1873,10 +1873,10 @@ export default function Gallery() {
return (
<>
- Image {index + 1} of {images.length}
+ Slika {index + 1} od {images.length}
@@ -1887,25 +1887,25 @@ export default function Gallery() {
}
let images = [{
- place: 'Penang, Malaysia',
+ place: 'Penang, Malezija',
src: 'https://i.imgur.com/FJeJR8M.jpg'
}, {
- place: 'Lisbon, Portugal',
+ place: 'Lisabon, Portugal',
src: 'https://i.imgur.com/dB2LRbj.jpg'
}, {
- place: 'Bilbao, Spain',
+ place: 'Bilbao, Španija',
src: 'https://i.imgur.com/z08o2TS.jpg'
}, {
- place: 'Valparaíso, Chile',
+ place: 'Valparaíso, Čile',
src: 'https://i.imgur.com/Y3utgTi.jpg'
}, {
- place: 'Schwyz, Switzerland',
+ place: 'Švic, Švajcarska',
src: 'https://i.imgur.com/JBbMpWY.jpg'
}, {
- place: 'Prague, Czechia',
+ place: 'Prag, Češka',
src: 'https://i.imgur.com/QwUKKmF.jpg'
}, {
- place: 'Ljubljana, Slovenia',
+ place: 'Ljubljana, Slovenija',
src: 'https://i.imgur.com/3aIiwfm.jpg'
}];
```
@@ -1918,7 +1918,7 @@ img { width: 150px; height: 150px; }
-You can provide a `key` to the `` tag. When that `key` changes, React will re-create the `` DOM node from scratch. This causes a brief flash when each image loads, so it's not something you'd want to do for every image in your app. But it makes sense if you want to ensure the image always matches the text.
+Možete dodeliti `key` u `` tag. Kada se taj `key` promeni, React će ponovo kreirati `` DOM čvor od nule. Ovo uzrokuje kratki bljesak kad se svaka učita, pa nije nešto što biste želeli za svaku sliku u aplikaciji. Ali, ima smisla ako želite da osigurate da se slika uvek poklapa sa tekstom.
@@ -1941,10 +1941,10 @@ export default function Gallery() {
return (
<>
- Image {index + 1} of {images.length}
+ Slika {index + 1} od {images.length}
-#### Fix misplaced state in the list {/*fix-misplaced-state-in-the-list*/}
+#### Popraviti pogrešno postavljen state u listi {/*fix-misplaced-state-in-the-list*/}
-In this list, each `Contact` has state that determines whether "Show email" has been pressed for it. Press "Show email" for Alice, and then tick the "Show in reverse order" checkbox. You will notice that it's _Taylor's_ email that is expanded now, but Alice's--which has moved to the bottom--appears collapsed.
+U ovoj listi, svaki `Contact` ima state koji odlučuje da li je "Prikaži email" pritisnut za njega. Pritisnite "Prikaži email" za Alice, a onda štiklirajte checkbox "Prikaži u obrnutom redosledu". Primetićete da je _Taylor-ov_ email sada proširen, a Alice-in--koji je pomeren na dno--sklopljen.
-Fix it so that the expanded state is associated with each contact, regardless of the chosen ordering.
+Popravite ovo tako da je proširen state povezan sa svakim kontaktom, nevezano od odabranog rasporeda.
@@ -2016,7 +2016,7 @@ export default function ContactList() {
setReverse(e.target.checked)
}}
/>{' '}
- Show in reverse order
+ Prikaži u obrnutom redosledu
{displayedContacts.map((contact, i) =>
@@ -2050,7 +2050,7 @@ export default function Contact({ contact }) {
>
);
@@ -2080,16 +2080,16 @@ button {
-The problem is that this example was using index as a `key`:
+Problem je što ovaj primer koristi indeks kao `key`:
```js
{displayedContacts.map((contact, i) =>
```
-However, you want the state to be associated with _each particular contact_.
+Međutim, želite da state bude povezan sa _svakim posebnim kontaktom_.
-Using the contact ID as a `key` instead fixes the issue:
+Upotreba ID-a kontakta kao `key`-a popravlja problem:
@@ -2115,7 +2115,7 @@ export default function ContactList() {
setReverse(e.target.checked)
}}
/>{' '}
- Show in reverse order
+ Prikaži u obrnutom redosledu
-State is associated with the tree position. A `key` lets you specify a named position instead of relying on order.
+State je povezan sa pozicijom u stablu. `key` vam omogućava da specificirate imenovanu poziciju umesto da se oslanjate na redosled.