You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/your-first-component.md
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,27 +82,27 @@ img { height: 200px; }
82
82
83
83
دستور `export default` یک پیشوند در زبان جاوااسکریپت است [standard JavaScript syntax](https://developer.mozilla.org/docs/web/javascript/reference/statements/export) (نه فقط در React), به شما اجازه میدهد که تابع اصلی خود را در فایل مشخص کنید و در فایل دیگر import کنید. (درباره Import بدانید [Importing and Exporting Components](/learn/importing-and-exporting-components)!)
84
84
85
-
### Step 2: تعریف و ایجاد تابع {/*step-2-define-the-function*/}
85
+
### قدم دوم: ساخت و تعریف توابع {/*step-2-define-the-function*/}
86
86
87
87
با دستور `function Profile() { }` شما میتوانید یک تابع جاوااسکریپتی با نام `Profile` تعریف کنید.
88
88
89
89
<Pitfall>
90
90
91
-
React components are regular JavaScript functions, but **their names must start with a capital letter**or they won't work!
91
+
کامپوننت های React همان توابع معمولی در جاوااسکریپت هستند, با این تفاوت که باید **حرف اول اسم آن از حروف بزرگ باشد**وگرنه ارور میدهد!
92
92
93
93
</Pitfall>
94
94
95
-
### Step 3: Add markup {/*step-3-add-markup*/}
95
+
### قدم سوم: اضافه کردن تگ HTML {/*step-3-add-markup*/}
96
96
97
-
The component returns an`<img />`tag with `src`and`alt`attributes. `<img />`is written like HTML, but it is actually JavaScript under the hood! This syntax is called [JSX](/learn/writing-markup-with-jsx), and it lets you embed markup inside JavaScript.
97
+
کامپوننت زیر یک تگ`<img />`را به همراه اتریبیوت های `src`و`alt`برمیگرداند. `<img />`مانند HTML نوشته میشود ولی این یک دستور جاوااسکریپتی است! این سینتکس [JSX](/learn/writing-markup-with-jsx) نام دارد, و به شما اجازه میدهد تا تگ های HTML را مستقیما در یک فایل جاوااسکریپت بنویسید.
98
98
99
-
Return statements can be written all on one line, as in this component:
99
+
دستور return را هم میتوان به این صورت در یک خط نوشت:
But if your markup isn't all on the same line as the `return` keyword, you must wrap it in a pair of parentheses:
105
+
اما اگر نمیتوانید کل تگ های HTML را در یک خط بنویسید فقط کافیست بعد از دستور return یک جفت پرانتز قرار بدهید و تگ هارا داخل آن بنویسید:
106
106
107
107
```js
108
108
return (
@@ -114,13 +114,13 @@ return (
114
114
115
115
<Pitfall>
116
116
117
-
Without parentheses, any code on the lines after `return`[will be ignored](https://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion-asi)!
117
+
بدون پرانتز, خط های بعد از دستور `return`[نادیده گرفته میشوند](https://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion-asi)!
118
118
119
119
</Pitfall>
120
120
121
-
## Using a component {/*using-a-component*/}
121
+
## استفاده از یک کامپوننت {/*using-a-component*/}
122
122
123
-
Now that you've defined your `Profile`component, you can nest it inside other components. For example, you can export a`Gallery`component that uses multiple `Profile`components:
123
+
بعد از اینکه کامپونت `Profile`خود را ساخته اید, الان وقت آن است که همان کامپوننت را در میان کامپوننت های دیگر قرار بدهید. به عنوان مثال شما میتوانید کامپوننت`Gallery`را به همراه چند کامپوننت `Profile`که داخل آن استفاده شده است را export بگیرید:
0 commit comments