Skip to content

Translating Components and Props page #24

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

Merged
merged 24 commits into from
Apr 16, 2019
Merged
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
986c636
Initial Vocabs Changes
helios1101 Mar 7, 2019
162ed0e
Rendering section to be started
helios1101 Mar 7, 2019
60e42d5
Few more lines translated
helios1101 Mar 8, 2019
2f53d77
Ready for review
helios1101 Mar 8, 2019
a3f0d07
Review1 Changes
helios1101 Mar 10, 2019
fcb77f8
Few more changes in Review1
helios1101 Mar 11, 2019
fdcdc88
Changes in Review2
helios1101 Mar 11, 2019
eb5648f
FinalChanges
helios1101 Mar 16, 2019
cb864d8
Merge branch 'master' into components-props
arshadkazmi42 Mar 16, 2019
a79c806
Review2-Changes
helios1101 Mar 17, 2019
95a9242
Merge branch 'components-props' of https://github.com/helios1101/hi.r…
helios1101 Mar 17, 2019
a812889
Some_More_Changes
helios1101 Mar 18, 2019
d38a47c
Merge branch 'master' into components-props
saranshkataria Mar 18, 2019
bc28399
Some_More_Changes2
helios1101 Mar 19, 2019
ac04a5d
Merge branch 'components-props' of https://github.com/helios1101/hi.r…
helios1101 Mar 19, 2019
91a1bc3
Names_Made_Generic
helios1101 Mar 20, 2019
48c6e14
Merge branch 'master' into components-props
saranshkataria Mar 20, 2019
6ea5fb8
secondLastChanges
helios1101 Mar 27, 2019
2a4adf3
Merge branch 'components-props' of https://github.com/helios1101/hi.r…
helios1101 Mar 27, 2019
91ed61d
Merge branch 'master' into components-props
arshadkazmi42 Apr 11, 2019
3317190
LastChanges
helios1101 Apr 12, 2019
d529658
Merge branch 'master' into components-props
saranshkataria Apr 16, 2019
fd9d568
fixed missing parenthesis
saranshkataria Apr 16, 2019
385b535
reworded last line
saranshkataria Apr 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 51 additions & 50 deletions content/docs/components-and-props.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: components-and-props
title: Components and Props
title: कौम्पोनॅन्ट तथा Props
permalink: docs/components-and-props.html
redirect_from:
- "docs/reusable-components.html"
Expand All @@ -15,58 +15,58 @@ redirect_from:
prev: rendering-elements.html
next: state-and-lifecycle.html
---
कौम्पोनॅन्टस हमें UI को स्वतंत्र, पुन: प्रयोज्य टुकड़ो में विभाजित करने में मदद करता है, तथा
हर हिस्से को अलग मानता है| यह पेज कौम्पोनॅन्टस का परिचय देता है| आपको [यहाँ पर विस्तृत कौम्पोनॅन्ट API reference](/docs/react-component.html) मिल जाएगा|

Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to the idea of components. You can find a [detailed component API reference here](/docs/react-component.html).
सैद्धांतिक रूप से, कौम्पोनॅन्टस जावास्क्रिप्ट फंक्शन्स जैसा है| वे अर्बिट्ररी इनपुट्स स्वीकार करते है (जिसे "props" बुलाया जाता है ) और React एलिमेंट्स रीटर्न करते हैं जो वर्णन करती है की स्क्रीन पर क्या आना चाहिए|

Conceptually, components are like JavaScript functions. They accept arbitrary inputs (called "props") and return React elements describing what should appear on the screen.
## फंक्शन्स तथा क्लास कौम्पोनॅन्टस {#function-and-class-components}

## Function and Class Components {#function-and-class-components}

The simplest way to define a component is to write a JavaScript function:
सबसे सरल तरीका एक कौम्पोनॅन्ट को परिभाषित करने का यह है की एक जावास्क्रिप्ट फंक्शन्स लिखा जाए:

```js
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
return <h1>नमस्ते, {props.name}</h1>;
}
```

This function is a valid React component because it accepts a single "props" (which stands for properties) object argument with data and returns a React element. We call such components "function components" because they are literally JavaScript functions.
यह फंक्शन्स एक वैध React कौम्पोनॅन्ट है क्योकि यह एक अकेला "props" (जो प्रॉपर्टीज का प्रतिनिधित्व करता है) ऑब्जेक्ट आर्गुमेंट डाटा सहित स्वीकार करता है और React एलिमेंट्स वापस करता है| हम उन कौम्पोनॅन्टस को "फंक्शन्स कौम्पोनॅन्टस" कहते है क्योकि वो वाकई में एक जावास्क्रिप्ट फंक्शन्स है|

You can also use an [ES6 class](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) to define a component:
आप कौम्पोनॅन्ट को परिभाषित करने के लिए एक [ES6 class](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Classes) का उपयोग भी कर सकते हैं:

```js
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
return <h1>नमस्ते, {this.props.name}</h1>;
}
}
```

The above two components are equivalent from React's point of view.
ऊपर के दोनों कौम्पोनॅन्टस बराबर है React's दृष्टिकोण से|

Classes have some additional features that we will discuss in the [next sections](/docs/state-and-lifecycle.html). Until then, we will use function components for their conciseness.
क्लासेज की कुछ अतिरिक्त विशेषताएं भी हैं जिसकी हम चर्चा [अगले खंड](/docs/state-and-lifecycle.html) में करेंगे| तब तक, हम उनकी संक्षिप्तता के लिए फ़ंक्शन कौम्पोनॅन्टस का उपयोग करेंगे।का

## Rendering a Component {#rendering-a-component}
## कौम्पोनॅन्ट रेंडरिंग {#rendering-a-component}

Previously, we only encountered React elements that represent DOM tags:
इससे पहले, हमने केवल वही React एलिमेंट्स का सामना किया जो DOM टैग्स को दर्शाता था:

```js
const element = <div />;
```

However, elements can also represent user-defined components:
हालाँकि, एलिमेंट्स उपयोगकर्ता परिभाषित कौम्पोनॅन्टस को भी दर्शा सकते है:

```js
const element = <Welcome name="Sara" />;
```

When React sees an element representing a user-defined component, it passes JSX attributes to this component as a single object. We call this object "props".
जब कभी भी React एक एलिमेंट को यूजर-डिफाइंड कौम्पोनॅन्ट का प्रतिनिधित्व करते हुए देखता है, तुरंत ही JSX ऐट्रिब्यूट्स को पास कर देता है इन कौम्पोनॅन्ट को, एक object के रूप में| हम इस object को "props" कहते हैं|

For example, this code renders "Hello, Sara" on the page:
उदाहरण के लिए, यह कोड पेज पर रेंडर करता है "नमस्ते, Sara":

```js{1,5}
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
return <h1>नमस्ते, {props.name}</h1>;
}

const element = <Welcome name="Sara" />;
Expand All @@ -78,28 +78,28 @@ ReactDOM.render(

[](codepen://components-and-props/rendering-a-component)

Let's recap what happens in this example:
चलो देकते है इस उदाहरण में क्या होता है:

1. We call `ReactDOM.render()` with the `<Welcome name="Sara" />` element.
2. React calls the `Welcome` component with `{name: 'Sara'}` as the props.
3. Our `Welcome` component returns a `<h1>Hello, Sara</h1>` element as the result.
4. React DOM efficiently updates the DOM to match `<h1>Hello, Sara</h1>`.
1. हम बुलाते है `ReactDOM.render()` को `<Welcome name="Sara" />` एलिमेंट्स से|
2. React बुलाते है `Welcome` कौम्पोनॅन्ट को `name: 'Sara'}` के साथ props के रूप में|
3. यह `Welcome` रेंडरस और वापस आती है `<h1>नमस्ते, Sara</h1>` एलिमेंट परिणाम के तौर पर|
4. React DOM कुशलता पूर्वक DOM को अपडेट करता है `<h1>नमस्ते, Sara</h1>` से|

>**Note:** Always start component names with a capital letter.
>**ध्यान दें:** हमेशा रेंडर की नाम की शुरुवात कैपिटल लेटर से होनी चाहिए|
>
>React treats components starting with lowercase letters as DOM tags. For example, `<div />` represents an HTML div tag, but `<Welcome />` represents a component and requires `Welcome` to be in scope.
>React उन कौम्पोनॅन्टस को DOM टैग्स मानता है जो लोअरकेस से स्टार्ट होते है| उदाहरण के लिए, `<div />` HTML div टैग्स को दर्शाता है, पर `<Welcome />` एक कौम्पोनॅन्ट को दर्शाता है और इसको Welcome स्कोप में चाहिए होता है|
>
>To learn more about the reasoning behind this convention, please read [JSX In Depth](/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized).
>इसके पीछे की सोच के बारे में और गहराई में जानने के लिए, कृपया [JSX गहराई में](/docs/jsx-in-depth.html#user-defined-components-must-be-capitalized) पढ़ें|

## Composing Components {#composing-components}
## कौम्पोनॅन्टस की रचना {#composing-components}

Components can refer to other components in their output. This lets us use the same component abstraction for any level of detail. A button, a form, a dialog, a screen: in React apps, all those are commonly expressed as components.
कौम्पोनॅन्टस अपने आउटपुट में अन्य कौम्पोनॅन्टस का उल्लेख कर सकते हैं| इससे हम विस्तार के किसी भी स्तर के लिए उन्ही कौम्पोनॅन्ट का उपयोग कर सकते हैं| एक बटन, एक फॉर्म, एक डायलॉग, एक स्क्रीन React ऍप्स में, इन सबको आमतौर पर कौम्पोनॅन्टस के रूप में व्यक्त किया जाता है|

For example, we can create an `App` component that renders `Welcome` many times:
उदाहरण के लिए, हम एक `App` बना सकते हैं जो Welcome को कई बार रेंडर करता है:

```js{8-10}
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
return <h1>नमस्ते, {props.name}</h1>;
}

function App() {
Expand All @@ -120,13 +120,13 @@ ReactDOM.render(

[](codepen://components-and-props/composing-components)

Typically, new React apps have a single `App` component at the very top. However, if you integrate React into an existing app, you might start bottom-up with a small component like `Button` and gradually work your way to the top of the view hierarchy.
आम तौर पर, नया React ऍप्स के पास एक अकेला `App` रेंडर होता है सबसे ऊपर में| हालाँकि, अगर आप एकीकृत करते हैं React को एक मौजूदा ऐप में, आप बेहद नीचे से छोटी चीज़ो के रेंडर्स से शुरुवात कर सकते हैं जैसे `Button` और धीरे-धीरे दृश्य पदानुक्रम के ऊपर तक जाते है|

## Extracting Components {#extracting-components}
## कौम्पोनॅन्टस निकालना {#extracting-components}

Don't be afraid to split components into smaller components.
कौम्पोनॅन्टस को छोटे छोटे कौम्पोनॅन्टस में विभाजित करने से डरना नहीं चाहिए|

For example, consider this `Comment` component:
उदाहरण के लिए, इस `Comment` कौम्पोनॅन्टस पर विचार करें:

```js
function Comment(props) {
Expand Down Expand Up @@ -154,11 +154,11 @@ function Comment(props) {

[](codepen://components-and-props/extracting-components)

It accepts `author` (an object), `text` (a string), and `date` (a date) as props, and describes a comment on a social media website.
यह `author` (एक ऑब्जेक्ट), `text` (एक string), और `date` (एक date) को props के जैसे स्वीकार करता है|

This component can be tricky to change because of all the nesting, and it is also hard to reuse individual parts of it. Let's extract a few components from it.
इस कौम्पोनॅन्टस की नेस्टिंग की वजह से इसको बदलना मुश्किल हो सकता है, तथा इसके अकेले पार्ट्स का पुन: उपयोग करना भी कठिन है| चलो कुछ कौम्पोनॅन्टस निकालते हैं|

First, we will extract `Avatar`:
सबसे पहले, हम निकालेंगे `Avatar`:

```js{3-6}
function Avatar(props) {
Expand All @@ -171,11 +171,11 @@ function Avatar(props) {
}
```

The `Avatar` doesn't need to know that it is being rendered inside a `Comment`. This is why we have given its prop a more generic name: `user` rather than `author`.
इस `Avatar` को जानने की जरूरत नहीं है कि यह एक `Comment` के अंदर रेंडर किया जा रहा है| इसलिए हमने इसके prop को एक ज्यादा सामान्य नाम दिया है : `author` के बजाय `user`|

We recommend naming props from the component's own point of view rather than the context in which it is being used.
Props का नामकरण हम कौम्पोनॅन्टस के अनुसार करने की सलाह देते हैं बजाय उस संदर्भ में किया जाए जिसमें इसका उपयोग किया जा रहा है|
Copy link
Member

Choose a reason for hiding this comment

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

can we break this into easier wording instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't find simple words.
I can just reverse the parts ...will that do ??

Copy link
Member

Choose a reason for hiding this comment

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

बजाय उस संदर्भ में किया जाए जिसमें इसका उपयोग किया जा रहा है| part is just a bit difficult, could we reword that and split it into 2 sentences that way?


We can now simplify `Comment` a tiny bit:
हम अब `Comment` को थोड़ा सरल कर सकते हैं:

```js{5}
function Comment(props) {
Expand All @@ -198,7 +198,7 @@ function Comment(props) {
}
```

Next, we will extract a `UserInfo` component that renders an `Avatar` next to the user's name:
अगला, हम एक निकालेंगे `UserInfo` कौम्पोनॅन्टस जो `Avatar` को यूजर'स नाम के पास रेंडर करता है:

```js{3-8}
function UserInfo(props) {
Expand All @@ -213,7 +213,7 @@ function UserInfo(props) {
}
```

This lets us simplify `Comment` even further:
यह हमे `Comment` को और भी ज्यादा आसान बनाने देता है:

```js{4}
function Comment(props) {
Expand All @@ -233,30 +233,31 @@ function Comment(props) {

[](codepen://components-and-props/extracting-components-continued)

Extracting components might seem like grunt work at first, but having a palette of reusable components pays off in larger apps. A good rule of thumb is that if a part of your UI is used several times (`Button`, `Panel`, `Avatar`), or is complex enough on its own (`App`, `FeedStory`, `Comment`), it is a good candidate to be a reusable component.
कौम्पोनॅन्टस निकालने के लिए पहली बार में ग्रंट का काम लग सकता है, लेकिन पुन: प्रयोज्य कौम्पोनॅन्टस के एक पैलेट होना बड़े ऐप्स में भुगतान करता है| यह एक अच्छा व्यवहार है की अगर आपके UI के पार्ट कई बार इस्तेमाल किये गए है (`Button`, `Panel`, `Avatar`), या अपने आप में काफी जटिल है (`App`, `FeedStory`, `Comment`), यह पुन: प्रयोज्य कौम्पोनॅन्ट होने के लिए एक अच्छा उम्मीदवार है|

## Props are Read-Only {#props-are-read-only}
## Props केवल-पढ़ने के लिए हैं {#props-are-read-only}

Whether you declare a component [as a function or a class](#function-and-class-components), it must never modify its own props. Consider this `sum` function:
जब भी आप एक कॉम्पोनेन्ट को [फंक्शन या क्लास के जैसे](#function-and-class-components) डिक्लेअर करें, इसे कभी भी खुदके props का संशोधित नहीं करना चाहिए| इस `sum` फंक्शन्स पर विचार करो:

```js
function sum(a, b) {
return a + b;
}
```

Such functions are called ["pure"](https://en.wikipedia.org/wiki/Pure_function) because they do not attempt to change their inputs, and always return the same result for the same inputs.
ऐसे फंक्शन्स को हम कहते है ["pure"](https://en.wikipedia.org/wiki/Pure_function) क्योंकि वे अपने इनपुट को बदलने का प्रयास नहीं करते हैं, और हमेशा समान इनपुट के लिए समान परिणाम लौटाते हैं|

In contrast, this function is impure because it changes its own input:
इसके विपरीत, यह फंक्शन्स impure है क्योंकि ऐसे अपना इनपुट खुद बदलता है:

```js
function withdraw(account, amount) {
account.total -= amount;
}
```

React is pretty flexible but it has a single strict rule:
React बहुत लचीला है, लेकिन इसमें एक सख्त नियम है:

**सारे React कौम्पोनॅन्टस को pure फंक्शन्स की तरह कार्य करना चाहिए अपने props के अनुसार|**

**All React components must act like pure functions with respect to their props.**

Of course, application UIs are dynamic and change over time. In the [next section](/docs/state-and-lifecycle.html), we will introduce a new concept of "state". State allows React components to change their output over time in response to user actions, network responses, and anything else, without violating this rule.
बेशक, अनुप्रयोग UI गतिशील हैं और समय के साथ बदलते हैं| अब [अगले सेक्शन](/docs/state-and-lifecycle.html) में, हम एक नई अवधारणा पेश करेंगे "state"| State React कौम्पोनॅन्टस को उपयोगकर्ता क्रियाओं के जवाब में समय के साथ अपने उत्पादन को बदलने के लिए अनुमति देता है, नेटवर्क प्रतिक्रियाएँ, और कुछ भी, इस नियम का उल्लंघन किए बिना|