Skip to content

Commit fe98258

Browse files
committed
translate from line 131 to 174 on importing and exporting components
1 parent 14a643e commit fe98258

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/content/learn/importing-and-exporting-components.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,50 +128,50 @@ import Gallery from './Gallery';
128128

129129
<DeepDive>
130130

131-
#### Default vs named exports {/*default-vs-named-exports*/}
131+
#### دستور default و export {/*default-vs-named-exports*/}
132132

133-
There are two primary ways to export values with JavaScript: default exports and named exports. So far, our examples have only used default exports. But you can use one or both of them in the same file. **A file can have no more than one _default_ export, but it can have as many _named_ exports as you like.**
133+
در اینجا دو راه اصلی وجود دارد که کامپوننت ها یا توابع و یا متغیر هایمان را export کنیم: default export و export خالی. تا اینجا در مثال ها از default export استفاده شده اما از این به بعد شما میتوانید از دستور export خالی هم استفاده کنید.
134134

135135
![Default and named exports](/images/docs/illustrations/i_import-export.svg)
136136

137-
How you export your component dictates how you must import it. You will get an error if you try to import a default export the same way you would a named export! This chart can help you keep track:
137+
اینکه چطور کامپوننت را ایمپورت کنید بستگی دارد به اینکه چطور آن را اکسپورت کنید. و اگر در جای خود استفاده نکنید به ارور برمیخورید.
138138

139139
| Syntax | Export statement | Import statement |
140140
| ----------- | ----------- | ----------- |
141141
| Default | `export default function Button() {}` | `import Button from './Button.js';` |
142142
| Named | `export function Button() {}` | `import { Button } from './Button.js';` |
143143

144-
When you write a _default_ import, you can put any name you want after `import`. For example, you could write `import Banana from './Button.js'` instead and it would still provide you with the same default export. In contrast, with named imports, the name has to match on both sides. That's why they are called _named_ imports!
144+
زمانی که شما به صورت پیش فرض ایمپورت میکنید (default import), شما میتوانید هر اسمی را بعد از import به عنوان نام متغیر بنویسید, حتی میتوانید مثلا بنویسید `import Banana from './Button.js'` ولی در ایمپورت هایی دیگر باید اسمی که در همان فایل اکسپورت کردید را بنویسید.
145145

146-
**People often use default exports if the file exports only one component, and use named exports if it exports multiple components and values.** Regardless of which coding style you prefer, always give meaningful names to your component functions and the files that contain them. Components without names, like `export default () => {}`, are discouraged because they make debugging harder.
146+
**معمولا از ایمپورت پیش فرض استفاده میشود, مخصوصا زمانی که یک کامپوننت یا تابع داخل یک فایل داریم. و زمانی که از ایمپورت معمولی (named import) که در یک فایل چندین تابع یا کامپوننت داشته باشیم** صرف نظر از اینکه از کدام روش استفاده میکنید, سعی کنید نام های مناسبی برای توابع و کامپوننت ها و ایمپورت ها انتخاب کنید. دستوری مانند `export default () => {}` مشکل زا هست و حذف میشود.
147147

148148
</DeepDive>
149149

150-
## Exporting and importing multiple components from the same file {/*exporting-and-importing-multiple-components-from-the-same-file*/}
150+
## اکسپورت و ایمپورت کردن چند کامپوننت از یک فایل {/*exporting-and-importing-multiple-components-from-the-same-file*/}
151151

152-
What if you want to show just one `Profile` instead of a gallery? You can export the `Profile` component, too. But `Gallery.js` already has a *default* export, and you can't have _two_ default exports. You could create a new file with a default export, or you could add a *named* export for `Profile`. **A file can only have one default export, but it can have numerous named exports!**
152+
برگردیم به مثال قبلی, فرض کنیم دو کامپوننت `Profile` و `Gallery` را داخل یک فایل داشته باشیم. نمیتوانیم به صورت پیش فرض از آنها اکسپورت بگیریم (export default). پس چکار کنیم؟ از اکسپورت معمولی (export) استفاده میکنیم. **در یک فایل فقط یک export default داشته باشد ولی به تعداد مدنظر میتوانید اکسپورت معمولی داشته باشید**
153153

154154
<Note>
155155

156-
To reduce the potential confusion between default and named exports, some teams choose to only stick to one style (default or named), or avoid mixing them in a single file. Do what works best for you!
156+
شاید پیش خود سوال کنید که از کدام استفاده کنم؟ یکسری از تیم ها فقط از export default استفاده کنند و مابقی توابع داخل فایل را با آن ادغام کنند. یا از export سراسر فایل استفاده کنند. اینکه کدام بهتر است به خودتان بستگی دارد.
157157

158158
</Note>
159159

160-
First, **export** `Profile` from `Gallery.js` using a named export (no `default` keyword):
160+
ابتدا, کامپوننت `Profile` را که در فایل `Gallery.js` موجود است را به اکسپورت بگیرید (از کلمه کلیدی `default` استفاده نکنید):
161161

162162
```js
163163
export function Profile() {
164164
// ...
165165
}
166166
```
167167

168-
Then, **import** `Profile` from `Gallery.js` to `App.js` using a named import (with the curly braces):
168+
سپس, کامپوننت `Profile` را از فایل `Gallery.js` به فایل `App.js` ایمپورت کنید (از علامت آکولاد استفاده کنید):
169169

170170
```js
171171
import { Profile } from './Gallery.js';
172172
```
173173

174-
Finally, **render** `<Profile />` from the `App` component:
174+
و در آخر, کامپوننت `<Profile />` در کامپوننت `App` رندر میشود:
175175

176176
```js
177177
export default function App() {

0 commit comments

Comments
 (0)