` सिंटैक्स](/reference/react/Fragment#rendering-a-list-of-fragments) का उपयोग करना होगा।
```js
import { Fragment } from 'react';
@@ -395,46 +396,47 @@ const listItems = people.map(person =>
);
```
-Fragments disappear from the DOM, so this will produce a flat list of ``, `
`, `
`, `
`, and so on.
+फ्रैगमेंट्स DOM से गायब हो जाते हैं, इसलिए यह `
`, `
`, `
`, `
`, और इस तरह की एक सपाट सूची उत्पन्न करेगा।
-### Where to get your `key` {/*where-to-get-your-key*/}
+### अपनी `key` कहां से प्राप्त करें {/*where-to-get-your-key*/}
-Different sources of data provide different sources of keys:
+डेटा के विभिन्न स्रोत विभिन्न प्रकार की keys प्रदान करते हैं:
-* **Data from a database:** If your data is coming from a database, you can use the database keys/IDs, which are unique by nature.
-* **Locally generated data:** If your data is generated and persisted locally (e.g. notes in a note-taking app), use an incrementing counter, [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) or a package like [`uuid`](https://www.npmjs.com/package/uuid) when creating items.
+* **डेटा डेटाबेस से:** यदि आपका डेटा डेटाबेस से आ रहा है, तो आप डेटाबेस keys/IDs का उपयोग कर सकते हैं, जो स्वभाव से अद्वितीय होती हैं।
-### Rules of keys {/*rules-of-keys*/}
+* **स्थानीय रूप से उत्पन्न डेटा:** यदि आपका डेटा स्थानीय रूप से उत्पन्न और संग्रहित किया गया है (जैसे कि नोट-लेने वाले ऐप में नोट्स), तो आइटम बनाते समय एक बढ़ता हुआ काउंटर, [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID) या [`uuid`](https://www.npmjs.com/package/uuid) जैसे पैकेज का उपयोग करें।
-* **Keys must be unique among siblings.** However, it’s okay to use the same keys for JSX nodes in _different_ arrays.
-* **Keys must not change** or that defeats their purpose! Don't generate them while rendering.
+### keys के नियम {/*rules-of-keys*/}
-### Why does React need keys? {/*why-does-react-need-keys*/}
+* **keys को सिबलिंग्स के बीच अद्वितीय होना चाहिए।** हालांकि, _विभिन्न_ arrays में JSX नोड्स के लिए एक ही keys का उपयोग करना ठीक है।
+* **keys को बदलना नहीं चाहिए** वरना उनका उद्देश्य ही समाप्त हो जाएगा! उन्हें रेंडर करते समय उत्पन्न न करें।
-Imagine that files on your desktop didn't have names. Instead, you'd refer to them by their order -- the first file, the second file, and so on. You could get used to it, but once you delete a file, it would get confusing. The second file would become the first file, the third file would be the second file, and so on.
+### React को keys की आवश्यकता क्यों है? {/*why-does-react-need-keys*/}
-File names in a folder and JSX keys in an array serve a similar purpose. They let us uniquely identify an item between its siblings. A well-chosen key provides more information than the position within the array. Even if the _position_ changes due to reordering, the `key` lets React identify the item throughout its lifetime.
+कल्पना करें कि आपके डेस्कटॉप पर फाइलों के नाम नहीं होते। इसके बजाय, आप उन्हें उनके क्रम के अनुसार संदर्भित करते — पहली फाइल, दूसरी फाइल, और इसी तरह। आप इसके आदी हो सकते थे, लेकिन जैसे ही आप एक फाइल को डिलीट करते, यह उलझन में डाल सकता था। दूसरी फाइल पहली फाइल बन जाती, तीसरी फाइल दूसरी फाइल बन जाती, और इसी तरह।
+
+एक फोल्डर में फाइल नाम और array में JSX keys का उद्देश्य समान होता है। ये हमें एक आइटम को उसके सिबलिंग्स के बीच अद्वितीय रूप से पहचानने की अनुमति देते हैं। एक अच्छे तरीके से चुनी गई key अधिक जानकारी देती है, न केवल array में स्थिति के बारे में। यहां तक कि यदि स्थिति पुनर्व्यवस्थित होने के कारण बदलती है, तो `key` React को आइटम को उसकी पूरी जीवनकाल के दौरान पहचानने में मदद करती है।
-You might be tempted to use an item's index in the array as its key. In fact, that's what React will use if you don't specify a `key` at all. But the order in which you render items will change over time if an item is inserted, deleted, or if the array gets reordered. Index as a key often leads to subtle and confusing bugs.
+आपको किसी आइटम के इंडेक्स को उसकी key के रूप में उपयोग करने का मन हो सकता है। दरअसल, यही React उपयोग करेगा यदि आप `key` को बिल्कुल निर्दिष्ट नहीं करते। लेकिन यदि कोई आइटम डाली जाती है, डिलीट होती है, या यदि array का पुनर्व्यवस्थापन होता है, तो आपके द्वारा रेंडर किए गए आइटम्स का क्रम समय के साथ बदल जाएगा। इंडेक्स को key के रूप में उपयोग करना अक्सर सूक्ष्म और उलझन भरे बग्स का कारण बनता है।
-Similarly, do not generate keys on the fly, e.g. with `key={Math.random()}`. This will cause keys to never match up between renders, leading to all your components and DOM being recreated every time. Not only is this slow, but it will also lose any user input inside the list items. Instead, use a stable ID based on the data.
+इसी तरह, तुरंत कीज़ उत्पन्न न करें, जैसे कि `key={Math.random()}` के साथ। इससे keys रेंडर के बीच कभी मेल नहीं खाएंगी, जिससे हर बार आपके सभी कौम्पोनॅन्ट्स और DOM को फिर से बनाना पड़ेगा। यह न केवल धीमा है, बल्कि यह सूची आइटम्स के अंदर किसी भी उपयोगकर्ता इनपुट को भी खो देगा। इसके बजाय, डेटा पर आधारित एक स्थिर ID का उपयोग करें।
-Note that your components won't receive `key` as a prop. It's only used as a hint by React itself. If your component needs an ID, you have to pass it as a separate prop: ``.
+ध्यान दें कि आपके कौम्पोनॅन्ट्स को `key` प्रॉप के रूप में प्राप्त नहीं होगी। इसे केवल React खुद द्वारा एक संकेत के रूप में उपयोग किया जाता है। यदि आपके कौम्पोनॅन्ट को ID की आवश्यकता है, तो आपको इसे एक अलग प्रॉप के रूप में पास करना होगा: ``।
-On this page you learned:
+इस पृष्ठ पर आपने सीखा:
-* How to move data out of components and into data structures like arrays and objects.
-* How to generate sets of similar components with JavaScript's `map()`.
-* How to create arrays of filtered items with JavaScript's `filter()`.
-* Why and how to set `key` on each component in a collection so React can keep track of each of them even if their position or data changes.
+* कैसे डेटा को कौम्पोनॅन्ट्स से बाहर ले जाकर डेटा संरचनाओं जैसे arrays और ऑब्जेक्ट्स में रखा जाए।
+* कैसे JavaScript के `map()` का उपयोग करके समान कौम्पोनॅन्ट्स के सेट बनाए जाएं।
+* कैसे JavaScript के `filter()` का उपयोग करके फ़िल्टर किए गए आइटम्स के arrays बनाए जाएं।
+* क्यों और कैसे प्रत्येक कौम्पोनॅन्ट पर `key` सेट किया जाए ताकि React उन्हें ट्रैक कर सके, भले ही उनकी स्थिति या डेटा बदल जाए।
@@ -442,11 +444,11 @@ On this page you learned:
-#### Splitting a list in two {/*splitting-a-list-in-two*/}
+#### एक सूची को दो में विभाजित करना {/*splitting-a-list-in-two*/}
-This example shows a list of all people.
+यह उदाहरण सभी लोगों की एक सूची दिखाता है।
-Change it to show two separate lists one after another: **Chemists** and **Everyone Else.** Like previously, you can determine whether a person is a chemist by checking if `person.profession === 'chemist'`.
+इसे दो अलग-अलग सूचियाँ एक के बाद एक दिखाने के लिए बदलें: **Chemists** और **बाकी सभी**। जैसा कि पहले था, आप यह निर्धारित कर सकते हैं कि कोई व्यक्ति केमिस्ट है या नहीं, इसके लिए आप `person.profession === 'chemist'` की जांच कर सकते हैं।
@@ -537,7 +539,7 @@ img { width: 100px; height: 100px; border-radius: 50%; }
-You could use `filter()` twice, creating two separate arrays, and then `map` over both of them:
+आप `filter()` का उपयोग दो बार कर सकते हैं, दो अलग-अलग arrays बना सकते हैं, और फिर दोनों पर `map` का उपयोग कर सकते हैं:
@@ -650,9 +652,9 @@ img { width: 100px; height: 100px; border-radius: 50%; }
-In this solution, the `map` calls are placed directly inline into the parent `` elements, but you could introduce variables for them if you find that more readable.
+इस समाधान में, `map` कॉल्स को सीधे पैरेंट `` elements में इनलाइन रखा गया है, लेकिन यदि आपको इसे अधिक readable लगे, तो आप उनके लिए वेरिएबल्स भी बना सकते हैं।
-There is still a bit duplication between the rendered lists. You can go further and extract the repetitive parts into a `` component:
+फिर भी रेंडर की गई सूचियों के बीच कुछ डुप्लिकेशन है। आप आगे बढ़ सकते हैं और पुनरावृत्त भागों को `` कौम्पोनॅन्ट में निकाल सकते हैं।
@@ -763,10 +765,9 @@ img { width: 100px; height: 100px; border-radius: 50%; }
```
+एक बहुत ही सतर्क पाठक यह नोटिस कर सकता है कि दो `filter` कॉल्स के साथ, हम प्रत्येक व्यक्ति के प्रोफेशन की जांच दो बार कर रहे हैं। एक प्रॉपर्टी की जांच करना बहुत तेज़ होता है, इसलिए इस उदाहरण में यह ठीक है। यदि आपकी लॉजिक उससे अधिक महंगी होती, तो आप `filter` कॉल्स को एक लूप से बदल सकते थे जो मैन्युअली arrays बनाता और प्रत्येक व्यक्ति की एक बार जांच करता।
-A very attentive reader might notice that with two `filter` calls, we check each person's profession twice. Checking a property is very fast, so in this example it's fine. If your logic was more expensive than that, you could replace the `filter` calls with a loop that manually constructs the arrays and checks each person once.
-
-In fact, if `people` never change, you could move this code out of your component. From React's perspective, all that matters is that you give it an array of JSX nodes in the end. It doesn't care how you produce that array:
+असल में, अगर `people` कभी नहीं बदलते, तो आप इस कोड को अपने कौम्पोनॅन्ट से बाहर ले जा सकते हैं। React के दृष्टिकोण से, यह महत्वपूर्ण नहीं है कि आप उस array को कैसे उत्पन्न करते हैं, केवल यह मायने रखता है कि आप अंत में उसे JSX नोड्स का array देते हैं।
@@ -884,13 +885,11 @@ img { width: 100px; height: 100px; border-radius: 50%; }
-#### Nested lists in one component {/*nested-lists-in-one-component*/}
-
-Make a list of recipes from this array! For each recipe in the array, display its name as an `` and list its ingredients in a ``.
-
+#### एक कौम्पोनॅन्ट में नेस्टेड सूचियाँ {/*nested-lists-in-one-component*/}
+इस array से रेसिपी की एक सूची बनाएं! array में प्रत्येक रेसिपी के लिए, उसका नाम `` के रूप में दिखाएं और उसकी सामग्री को `` में सूचीबद्ध करें।
-This will require nesting two different `map` calls.
+इसके लिए दो अलग-अलग `map` कॉल्स को नेस्ट करना होगा।
@@ -928,7 +927,7 @@ export const recipes = [{
-Here is one way you could go about it:
+यहाँ एक तरीका है जिससे आप इसे कर सकते हैं:
@@ -974,13 +973,13 @@ export const recipes = [{
-Each of the `recipes` already includes an `id` field, so that's what the outer loop uses for its `key`. There is no ID you could use to loop over ingredients. However, it's reasonable to assume that the same ingredient won't be listed twice within the same recipe, so its name can serve as a `key`. Alternatively, you could change the data structure to add IDs, or use index as a `key` (with the caveat that you can't safely reorder ingredients).
+`recipes` में से प्रत्येक के पास पहले से ही एक `id` फ़ील्ड है, इसलिए बाहरी लूप इसके `key` के रूप में इसका उपयोग करता है। सामग्री पर लूप करने के लिए कोई ID नहीं है, हालांकि यह मानना उचित है कि एक ही सामग्री को एक ही रेसिपी में दो बार सूचीबद्ध नहीं किया जाएगा, इसलिए उसका नाम `key` के रूप में काम कर सकता है। वैकल्पिक रूप से, आप डेटा संरचना को बदल सकते हैं और IDs जोड़ सकते हैं, या `key` के रूप में इंडेक्स का उपयोग कर सकते हैं (इस चेतावनी के साथ कि आप सामग्री को सुरक्षित रूप से पुनर्व्यवस्थित नहीं कर सकते)।
-#### Extracting a list item component {/*extracting-a-list-item-component*/}
+#### एक सूची आइटम कौम्पोनॅन्ट निकालना {/*extracting-a-list-item-component*/}
-This `RecipeList` component contains two nested `map` calls. To simplify it, extract a `Recipe` component from it which will accept `id`, `name`, and `ingredients` props. Where do you place the outer `key` and why?
+यह `RecipeList` कौम्पोनॅन्ट दो नेस्टेड `map` कॉल्स को शामिल करता है। इसे सरल बनाने के लिए, इससे एक `Recipe` कौम्पोनॅन्ट निकालें जो `id`, `name`, और `ingredients` प्रॉप्स को स्वीकार करेगा। आप बाहरी `key` को कहां रखें और क्यों?
@@ -1028,7 +1027,7 @@ export const recipes = [{
-You can copy-paste the JSX from the outer `map` into a new `Recipe` component and return that JSX. Then you can change `recipe.name` to `name`, `recipe.id` to `id`, and so on, and pass them as props to the `Recipe`:
+आप बाहरी `map` से JSX को कॉपी-पेस्ट करके एक नया `Recipe` कौम्पोनॅन्ट बना सकते हैं और उस JSX को रिटर्न कर सकते हैं। फिर आप `recipe.name` को `name`, `recipe.id` को `id`, और इसी तरह बदल सकते हैं, और उन्हें प्रॉप्स के रूप में `Recipe` को पास कर सकते हैं।
@@ -1080,15 +1079,15 @@ export const recipes = [{
-Here, `` is a syntax shortcut saying "pass all properties of the `recipe` object as props to the `Recipe` component". You could also write each prop explicitly: ``.
+यहाँ, `` एक syntax शॉर्टकट है जो यह कहता है "सब कुछ प्रॉपर्टीज़ `recipe` ऑब्जेक्ट की `Recipe` कौम्पोनॅन्ट को प्रॉप्स के रूप में पास करें"। आप प्रत्येक प्रॉप को स्पष्ट रूप से भी लिख सकते हैं: ``।
-**Note that the `key` is specified on the `` itself rather than on the root `` returned from `Recipe`.** This is because this `key` is needed directly within the context of the surrounding array. Previously, you had an array of `
`s so each of them needed a `key`, but now you have an array of `
`s. In other words, when you extract a component, don't forget to leave the `key` outside the JSX you copy and paste.
+**ध्यान दें कि `key` को `` पर ही निर्दिष्ट किया गया है, न कि `Recipe` से रिटर्न होने वाले रूट `` पर।** इसका कारण यह है कि यह `key` सीधे आसपास की array के संदर्भ में आवश्यक है। पहले, आपके पास `
` का एक array था, इसलिए प्रत्येक को एक `key` की आवश्यकता थी, लेकिन अब आपके पास `
` का एक array है। दूसरे शब्दों में, जब आप एक कौम्पोनॅन्ट को निकालते हैं, तो यह न भूलें कि `key` को JSX से बाहर छोड़ दें जिसे आप कॉपी और पेस्ट करते हैं।
-#### List with a separator {/*list-with-a-separator*/}
+#### एक सेपरेटर के साथ सूची {/*list-with-a-separator*/}
-This example renders a famous haiku by Tachibana Hokushi, with each line wrapped in a `` tag. Your job is to insert an `
` separator between each paragraph. Your resulting structure should look like this:
+यह उदाहरण ताचिबाना होकुशी की एक प्रसिद्ध हैकू को रेंडर करता है, जिसमें प्रत्येक पंक्ति को `` टैग में लपेटा गया है। आपका काम है कि प्रत्येक पैराग्राफ के बीच एक `
` सेपरेटर डालें। आपका परिणामस्वरूप संरचना इस तरह दिखनी चाहिए:
```js
@@ -1100,7 +1099,7 @@ This example renders a famous haiku by Tachibana Hokushi, with each line wrapped
```
-A haiku only contains three lines, but your solution should work with any number of lines. Note that `
` elements only appear *between* the `` elements, not in the beginning or the end!
+एक हैकू में केवल तीन पंक्तियाँ होती हैं, लेकिन आपका समाधान किसी भी संख्या में पंक्तियों के लिए काम करना चाहिए। ध्यान दें कि `
` तत्व केवल `` elements के *बीच* दिखाई देने चाहिए, न कि शुरुआत में या अंत में!
@@ -1143,17 +1142,17 @@ hr {
-(This is a rare case where index as a key is acceptable because a poem's lines will never reorder.)
+(यह एक दुर्लभ मामला है जहां इंडेक्स को एक की के रूप में उपयोग किया जा सकता है क्योंकि एक कविता की पंक्तियाँ कभी भी फिर से क्रमबद्ध नहीं होती हैं।)
-You'll either need to convert `map` to a manual loop, or use a Fragment.
+आपको या तो `map` को एक मैनुअल लूप में बदलने की आवश्यकता होगी, या एक Fragment का उपयोग करना होगा।
-You can write a manual loop, inserting `
` and `...
` into the output array as you go:
+आप एक मैनुअल लूप लिख सकते हैं, `
` और `...
` को आउटपुट array में डालते हुए:
@@ -1208,9 +1207,9 @@ hr {
-Using the original line index as a `key` doesn't work anymore because each separator and paragraph are now in the same array. However, you can give each of them a distinct key using a suffix, e.g. `key={i + '-text'}`.
+मूल पंक्ति इंडेक्स को `key` के रूप में इस्तेमाल करना अब काम नहीं करेगा क्योंकि अब प्रत्येक सेपरेटर और पैराग्राफ एक ही array में हैं। हालांकि, आप उन्हें एक अलग `key` दे सकते हैं एक उपसर्ग का उपयोग करते हुए, जैसे कि `key={i + '-text'}`।
-Alternatively, you could render a collection of Fragments which contain `
` and `...
`. However, the `<>...>` shorthand syntax doesn't support passing keys, so you'd have to write `` explicitly:
+वैकल्पिक रूप से, आप Fragments का एक संग्रह रेंडर कर सकते हैं जिसमें `
` और `...
` शामिल हों। हालांकि, `<>...>` संक्षिप्त सिंटैक्स keys पास करने का समर्थन नहीं करता है, इसलिए आपको `` को स्पष्ट रूप से लिखना होगा।
@@ -1256,7 +1255,7 @@ hr {
-Remember, Fragments (often written as `<> >`) let you group JSX nodes without adding extra ``s!
+याद रखें, Fragments (जो अक्सर `<> >` के रूप में लिखा जाता है) आपको अतिरिक्त `
` जोड़ने के बिना JSX नोड्स को समूहित करने की अनुमति देते हैं!