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 --- -You will often want to display multiple similar components from a collection of data. You can use the [JavaScript array methods](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array#) to manipulate an array of data. On this page, you'll use [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) and [`map()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map) with React to filter and transform your array of data into an array of components. +Često ćete želeti da prikažete više sličnih komponenata iz kolekcije podataka. Možete koristiti [JavaScript metode za nizove](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array#) kako bi manipulisali nizovima podataka. U ovom članku, koristićete [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) i [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) da uz React filtrirate i transformišete vaš niz podataka u niz komponenata. -* How to render components from an array using JavaScript's `map()` -* How to render only specific components using JavaScript's `filter()` -* When and why to use React keys +* Kako da renderujete komponente na osnovu niza uz pomoć JavaScript-ovog `map()`-a +* Kako da renderujete samo specifične komponente uz pomoć JavaScript-ovog `filter()`-a +* Kada i zašto da koristite React ključeve -## Rendering data from arrays {/*rendering-data-from-arrays*/} +## Renderovanje podataka iz nizova {/*rendering-data-from-arrays*/} -Say that you have a list of content. +Recimo da imate sledeću listu. ```js ``` -The only difference among those list items is their contents, their data. You will often need to show several instances of the same component using different data when building interfaces: from lists of comments to galleries of profile images. In these situations, you can store that data in JavaScript objects and arrays and use methods like [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) and [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) to render lists of components from them. +Jedina razlika u stavkama liste je njihov sadržaj, njihovi podaci. Često ćete imati potrebu da prikažete nekoliko instanci iste komponente sa drugačijim podacima kada pravite interfejse: od liste komentara do galerije profilnih slika. U takvim situacijama, možete čuvati podatke u JavaScript objektima i nizovima i upotrebiti metode kao što su [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) i [`filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) da od njih renderujete listu komponenata. -Here’s a short example of how to generate a list of items from an array: +Evo kratkog primera kako da generišete listu stavki na osnovu niza: -1. **Move** the data into an array: +1. **Pomerite** podatke u niz: ```js const people = [ - 'Creola Katherine Johnson: mathematician', - 'Mario José Molina-Pasquel Henríquez: chemist', - 'Mohammad Abdus Salam: physicist', - 'Percy Lavon Julian: chemist', - 'Subrahmanyan Chandrasekhar: astrophysicist' + 'Creola Katherine Johnson: matematičar', + 'Mario José Molina-Pasquel Henríquez: hemičar', + 'Mohammad Abdus Salam: fizičar', + 'Percy Lavon Julian: hemičar', + 'Subrahmanyan Chandrasekhar: astrofizičar' ]; ``` -2. **Map** the `people` members into a new array of JSX nodes, `listItems`: +2. **Mapirajte** `people` članove u novi niz JSX čvorova, `listItems`: ```js const listItems = people.map(person =>
  • {person}
  • ); ``` -3. **Return** `listItems` from your component wrapped in a `