Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translated Lists-and-Keys page #25

Merged
merged 29 commits into from Jun 3, 2019
Merged
Changes from 22 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
730d233
Translated Lists-and-Keys page
aliana17 Mar 21, 2019
ac0415e
Merge branch 'master' into lists-and-keys
aliana17 Mar 21, 2019
4cfdb3c
Merge branch 'master' into lists-and-keys
arshadkazmi42 Mar 22, 2019
6fe7640
Merge branch 'master' into lists-and-keys
arshadkazmi42 Mar 27, 2019
273a390
Changes made for the first part
aliana17 Mar 27, 2019
4007c82
further changes in same feedback
aliana17 Mar 28, 2019
5b13e08
Merge branch 'master' into lists-and-keys
arshadkazmi42 Mar 29, 2019
62cee18
removed extra space
aliana17 Apr 1, 2019
7b7cffb
Merge branch 'master' into lists-and-keys
arshadkazmi42 Apr 2, 2019
a6faf50
Further Changes
aliana17 Apr 2, 2019
b56b266
Further changes Done
aliana17 Apr 4, 2019
a3ca740
Merge branch 'master' into lists-and-keys
arshadkazmi42 Apr 4, 2019
07d5994
Merge branch 'master' into lists-and-keys
arshadkazmi42 Apr 10, 2019
58b853e
Pending Changes Done
aliana17 Apr 6, 2019
35d9acc
Further changes
aliana17 Apr 15, 2019
263c4ba
Changes Done
aliana17 Apr 26, 2019
05f67f9
Further Changes
aliana17 Apr 28, 2019
b00935b
Line break added
arshadkazmi42 May 5, 2019
29d5948
Merge branch 'master' into lists-and-keys
arshadkazmi42 May 5, 2019
677454f
Merge branch 'master' into lists-and-keys
arshadkazmi42 May 8, 2019
a7b1b25
Merge branch 'master' into lists-and-keys
saranshkataria May 20, 2019
1b9fce1
Changes done as per feedback
aliana17 May 23, 2019
04bef7e
Merge branch 'master' into lists-and-keys
saranshkataria May 23, 2019
d627b83
Changes Done
aliana17 May 25, 2019
c3a9cb3
updated typo
saranshkataria May 26, 2019
3653264
Merge branch 'master' into lists-and-keys
saranshkataria May 26, 2019
d0f1542
commited changes
aliana17 May 31, 2019
33c74ab
Merge branch 'master' into lists-and-keys
saranshkataria Jun 3, 2019
9e277a7
final changes to translation of list and keys
saranshkataria Jun 3, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
79 changes: 39 additions & 40 deletions content/docs/lists-and-keys.md
@@ -1,30 +1,30 @@
---
---
id: lists-and-keys
title: Lists and Keys
permalink: docs/lists-and-keys.html
prev: conditional-rendering.html
next: forms.html
---

First, let's review how you transform lists in JavaScript.
पहले, आइए समीक्षा करें कि आप जावास्क्रिप्ट में लिस्ट्स को कैसे बदलते हैं।

Given the code below, we use the [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) function to take an array of `numbers` and double their values. We assign the new array returned by `map()` to the variable `doubled` and log it:
नीचे दिए गए कोड में हम `numbers` की एक array के मूल्यों को दोगुना करने के लिए [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) फ़ंक्शन का उपयोग करते हैं। हम `map()` द्वारा दिए गए नए array को `doubled` नाम के वेरिएबल को सौपते हैं और फिर लॉग करते हैं।

```javascript{2}
const numbers = [1, 2, 3, 4, 5];
const doubled = numbers.map((number) => number * 2);
console.log(doubled);
```

This code logs `[2, 4, 6, 8, 10]` to the console.
यह कोड [2, 4, 6, 8, 10] को कंसोल main लोग करता है।

In React, transforming arrays into lists of [elements](/docs/rendering-elements.html) is nearly identical.
React में, array को [एलिमेंट्स](/docs/rendering-elements.html) की लिस्ट में बदलना लगभग समान है।

### Rendering Multiple Components {#rendering-multiple-components}
### कई कौम्पोनॅन्टस को रेंडर करना {#rendering-multiple-components}

You can build collections of elements and [include them in JSX](/docs/introducing-jsx.html#embedding-expressions-in-jsx) using curly braces `{}`.
आप एलिमेंट्स का संग्रह बना सकते हैं और कर्ली ब्रेसिज़ `{}` का उपयोग करके [उन्हें JSX में शामिल कर सकते हैं।](/docs/introducing-jsx.html#embedding-expressions-in-jsx)

Below, we loop through the `numbers` array using the JavaScript [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) function. We return a `<li>` element for each item. Finally, we assign the resulting array of elements to `listItems`:
हमने जावास्क्रिप्ट [`map()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) फंक्शन का उपयोग करके `numbers` नाम की array में लूप लगाया है। हमने प्रत्येक आइटम के लिए `<li>` एलिमेंट को रिटर्न किया है। अंत में, हम परिणामस्वरूप आयी हुई एलिमेंट्स की array को `listItems` को सौपते है:

```javascript{2-4}
const numbers = [1, 2, 3, 4, 5];
Expand All @@ -33,7 +33,7 @@ const listItems = numbers.map((number) =>
);
```

We include the entire `listItems` array inside a `<ul>` element, and [render it to the DOM](/docs/rendering-elements.html#rendering-an-element-into-the-dom):
हम पुरे `listItems` array को `<ul>` एलिमेंट में शामिल करके इसे [DOM में रेंडर करते हैं](/docs/rendering-elements.html#rendering-an-element-into-the-dom):

```javascript{2}
ReactDOM.render(
Expand All @@ -42,15 +42,15 @@ ReactDOM.render(
);
```

[**Try it on CodePen**](https://codepen.io/gaearon/pen/GjPyQr?editors=0011)
[**इसे CodePen पर आज़माएँ**](https://codepen.io/gaearon/pen/GjPyQr?editors=0011)

This code displays a bullet list of numbers between 1 and 5.
यह कोड 1 से 5 के बीच संख्याओं की एक बुलेट लिस्ट प्रदर्शित करता है।

### Basic List Component {#basic-list-component}
### मूल लिस्टस कौम्पोनॅन्ट {#basic-list-component}

Usually you would render lists inside a [component](/docs/components-and-props.html).
आमतौर पर आप एक [कौम्पोनॅन्ट](/docs/components-and-props.html) के अंदर लिस्ट रेंडर करते हैं।

We can refactor the previous example into a component that accepts an array of `numbers` and outputs a list of elements.
हम पिछले उदाहरण को एक कौम्पोनॅन्ट में बदल सकते हैं जो `numbers` की एक array को स्वीकार करता है और एलिमेंटस की लिस्ट को आउटपुट करता है।

```javascript{3-5,7,13}
function NumberList(props) {
Expand All @@ -70,9 +70,9 @@ ReactDOM.render(
);
```

When you run this code, you'll be given a warning that a key should be provided for list items. A "key" is a special string attribute you need to include when creating lists of elements. We'll discuss why it's important in the next section.
जब आप यह कोड चलाते हैं, तो आपको एक चेतावनी दी जाती है कि लिस्ट आइटम के लिए एक key प्रदान की जानी चाहिए। "key" एक विशेष स्ट्रिंग एट्रिब्यूट है जिसे आपको एलिमेंटस की सूची बनाते समय शामिल करने की आवश्यकता होती है। हम अगले भाग में चर्चा करेंगे कि यह महत्वपूर्ण क्यों है।

Let's assign a `key` to our list items inside `numbers.map()` and fix the missing key issue.
आइए `numbers.map()` के अंदर हमारी लिस्ट आइटम को एक `key`असाइन करें और लापता key की समस्या को ठीक करें।

```javascript{4}
function NumberList(props) {
Expand All @@ -94,11 +94,11 @@ ReactDOM.render(
);
```

[**Try it on CodePen**](https://codepen.io/gaearon/pen/jrXYRR?editors=0011)
[**इसे CodePen पर आज़माएँ**](https://codepen.io/gaearon/pen/jrXYRR?editors=0011)

## Keys {#keys}

Keys help React identify which items have changed, are added, or are removed. Keys should be given to the elements inside the array to give the elements a stable identity:
Keys React को पहचानने में मदद करती हैं कि कौन से आइटम ऐड किये गए हैं, या हटा दिए गए हैं। एलिमेंटस को स्थिर पहचान देने के लिए array के अंदर एलिमेंट्स को key दी जानी चाहिए:
saranshkataria marked this conversation as resolved.
Show resolved Hide resolved

```js{3}
const numbers = [1, 2, 3, 4, 5];
Expand All @@ -109,7 +109,7 @@ const listItems = numbers.map((number) =>
);
```

The best way to pick a key is to use a string that uniquely identifies a list item among its siblings. Most often you would use IDs from your data as keys:
Key चुनने का सबसे अच्छा तरीका एक string का उपयोग करना है जो विशिष्ट रूप से अपने सिब्लिंग्स के बीच एक लिस्ट आइटम की पहचान करता है। अक्सर आप अपने डेटा की IDs को key के रूप में उपयोग करेंगे:

```js{2}
const todoItems = todos.map((todo) =>
Expand All @@ -119,7 +119,7 @@ const todoItems = todos.map((todo) =>
);
```

When you don't have stable IDs for rendered items, you may use the item index as a key as a last resort:
जब आपके पास प्रदान की गई वस्तुओं के लिए स्थिर ID नहीं है, तो आप अंतिम उपाय के रूप में आइटम इंडेक्स का key के रूप में उपयोग कर सकते हैं:

```js{2,3}
const todoItems = todos.map((todo, index) =>
Expand All @@ -130,17 +130,17 @@ const todoItems = todos.map((todo, index) =>
);
```

We don't recommend using indexes for keys if the order of items may change. This can negatively impact performance and may cause issues with component state. Check out Robin Pokorny's article for an [in-depth explanation on the negative impacts of using an index as a key](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318). If you choose not to assign an explicit key to list items then React will default to using indexes as keys.
यदि आइटम का क्रम बदल सकता है तो हम key के लिए इंडेक्स का उपयोग ना करने की सिफारिश करते हैं। यह प्रदर्शन को नकारात्मक रूप से प्रभावित कर सकता है और कौम्पोनॅन्ट की अवस्था के साथ समस्या पैदा कर सकता है। Robin Pokorny के [इंडेक्स को key के रूप में उपयोग करने के नकारात्मक प्रभाव](https://medium.com/@robinpokorny/index-as-a-key-is-an-anti-pattern-e0349aece318) के आर्टिकल को देखें। यदि आप आइटमों को सूचीबद्ध करने के लिए एक स्पष्ट key निर्दिष्ट नहीं करते हैं तो React key के रूप में इंडेक्स का उपयोग करता है।
saranshkataria marked this conversation as resolved.
Show resolved Hide resolved

Here is an [in-depth explanation about why keys are necessary](/docs/reconciliation.html#recursing-on-children) if you're interested in learning more.
यदि आप अधिक सीखने में रुचि रखते हैं, [तो key क्यों आवश्यक है](/docs/reconciliation.html#recursing-on-children), इस बारे में गहराई से व्याख्या करें।
saranshkataria marked this conversation as resolved.
Show resolved Hide resolved

### Extracting Components with Keys {#extracting-components-with-keys}
### Key के साथ कौम्पोनॅन्टस निकालना {#extracting-components-with-keys}

Keys only make sense in the context of the surrounding array.
Keys केवल उनके array के लिए ही होती है।
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect translation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not getting it's correct translation . Please suggest it's hindi translation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keys केवल आस-पास के array के संदर्भ में ही समझ में आती हैं।


For example, if you [extract](/docs/components-and-props.html#extracting-components) a `ListItem` component, you should keep the key on the `<ListItem />` elements in the array rather than on the `<li>` element in the `ListItem` itself.
उदाहरण के लिए, यदि आप एक ListItem कौम्पोनॅन्ट को [निकालते](/docs/components-and-props.html#extracting-components) हैं, तो आपको key `ListItem` के `<li>` एलिमेंट पर रखने के बजाये array में `<ListItem />` एलिमेंट पर रखनी चाहिए।

**Example: Incorrect Key Usage**
**उदाहरण: key का गलत उपयोग**

```javascript{4,5,14,15}
function ListItem(props) {
Expand Down Expand Up @@ -173,7 +173,7 @@ ReactDOM.render(
);
```

**Example: Correct Key Usage**
**उदाहरण: key का सही उपयोग**

```javascript{2,3,9,10}
function ListItem(props) {
Expand Down Expand Up @@ -202,13 +202,12 @@ ReactDOM.render(
);
```

[**Try it on CodePen**](https://codepen.io/gaearon/pen/ZXeOGM?editors=0010)

A good rule of thumb is that elements inside the `map()` call need keys.
[**इसे CodePen पर आज़माएँ**](https://codepen.io/gaearon/pen/ZXeOGM?editors=0010)

### Keys Must Only Be Unique Among Siblings {#keys-must-only-be-unique-among-siblings}
एक अच्छा नियम यह है कि एलिमेंटस को `map()` कॉल के समय पर key की जरुरत होती है।

Keys used within arrays should be unique among their siblings. However they don't need to be globally unique. We can use the same keys when we produce two different arrays:
### Keys सिर्फ़ सिब्लिंग्स के बीच अद्वितीय होनी चाहिए {#keys-must-only-be-unique-among-siblings}
Arrays के भीतर उपयोग की जाने वाली key उनके सिब्लिंग्स के बीच अद्वितीय होनी चाहिए। हालाँकि उन्हें विश्व स्तर पर अद्वितीय होने की आवश्यकता नहीं है। जब हम दो अलग-अलग arrays का उत्पादन करते हैं, तो हम उसी key का उपयोग कर सकते हैं:
saranshkataria marked this conversation as resolved.
Show resolved Hide resolved

```js{2,5,11,12,19,21}
function Blog(props) {
Expand Down Expand Up @@ -246,9 +245,9 @@ ReactDOM.render(
);
```

[**Try it on CodePen**](https://codepen.io/gaearon/pen/NRZYGN?editors=0010)
[**इसे CodePen पर आज़माएँ**](https://codepen.io/gaearon/pen/NRZYGN?editors=0010)

Keys serve as a hint to React but they don't get passed to your components. If you need the same value in your component, pass it explicitly as a prop with a different name:
Keys React के लिए संकेत के रूप में काम करती हैं लेकिन वे आपके कौम्पोनॅन्टस को पास नहीं की जाती हैं। यदि आपको अपने कौम्पोनॅन्ट में समान वैल्यू की आवश्यकता है, तो इसे अलग नाम के साथ स्पष्ट रूप से prop की तरह पास करें:
saranshkataria marked this conversation as resolved.
Show resolved Hide resolved

```js{3,4}
const content = posts.map((post) =>
Expand All @@ -259,11 +258,11 @@ const content = posts.map((post) =>
);
```

With the example above, the `Post` component can read `props.id`, but not `props.key`.
ऊपर के उदाहरण के साथ, `Post` कौम्पोनॅन्ट `props.id` पढ़ सकता है, लेकिन `props.key` नहीं।

### Embedding map() in JSX {#embedding-map-in-jsx}
### JSX में map() की एम्बेडिंग {#embedding-map-in-jsx}
saranshkataria marked this conversation as resolved.
Show resolved Hide resolved

In the examples above we declared a separate `listItems` variable and included it in JSX:
ऊपर दिए गए उदाहरणों में हमने एक अलग `listItems` वेरिएबल को घोषित किया था और इसे JSX में शामिल किया था:

```js{3-6}
function NumberList(props) {
Expand All @@ -280,7 +279,7 @@ function NumberList(props) {
}
```

JSX allows [embedding any expression](/docs/introducing-jsx.html#embedding-expressions-in-jsx) in curly braces so we could inline the `map()` result:
JSX कर्ली ब्रेसिज़ में किसी भी [एक्सप्रेशन की एम्बेडिंग](/docs/introducing-jsx.html#embedding-expressions-in-jsx) करने की अनुमति देता है ताकि हम `map()` के परिणाम को इनलाइन कर सकें:

```js{5-8}
function NumberList(props) {
Expand All @@ -296,6 +295,6 @@ function NumberList(props) {
}
```

[**Try it on CodePen**](https://codepen.io/gaearon/pen/BLvYrB?editors=0010)
[**इसे CodePen पर आज़माएँ**](https://codepen.io/gaearon/pen/BLvYrB?editors=0010)

Sometimes this results in clearer code, but this style can also be abused. Like in JavaScript, it is up to you to decide whether it is worth extracting a variable for readability. Keep in mind that if the `map()` body is too nested, it might be a good time to [extract a component](/docs/components-and-props.html#extracting-components).
कभी-कभी इसका परिणाम स्पष्ट कोड होता है, लेकिन इस शैली का दुरुपयोग भी किया जा सकता है। जैसे जावास्क्रिप्ट में ये आपको तय करना होता है की readability के लिए एक variable को extract करना चाहिए या नहीं। ध्यान रखें कि यदि `map()` बॉडी बहुत नेस्टेड है, तो [कंपोनेंट निकालने](/docs/components-and-props.html#extracting-components) का अच्छा समय हो सकता है।