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/react-compiler/installation.md
+62-62Lines changed: 62 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,60 +1,60 @@
1
1
---
2
-
title: Installation
2
+
title: نصب
3
3
---
4
4
5
5
<Intro>
6
-
This guide will help you install and configure React Compiler in your React application.
6
+
این راهنما به شما کمک میکند تا کامپایلر React را در برنامه React خود نصب و پیکربندی کنید.
7
7
</Intro>
8
8
9
9
<YouWillLearn>
10
10
11
-
*How to install React Compiler
12
-
*Basic configuration for different build tools
13
-
*How to verify your setup is working
11
+
*نحوهٔ نصب کامپایلر ریاکت
12
+
*پیکربندی پایه برای ابزارهای بیلد مختلف
13
+
*چگونه اطمینان حاصل کنید که تنظیمات شما کار میکند
14
14
15
15
</YouWillLearn>
16
16
17
-
## Prerequisites {/*prerequisites*/}
17
+
## پیشنیازها {/*prerequisites*/}
18
18
19
-
React Compiler is designed to work best with React 19, but it also supports React 17 and 18. Learn more about [React version compatibility](/reference/react-compiler/target).
19
+
کامپایلر ریاکت برای کار با ریاکت 19 طراحی شده است، اما از ریاکت 17 و 18 نیز پشتیبانی میکند. درباره [سازگاری نسخههای ریاکت](/reference/react-compiler/target) بیشتر بدانید.
20
20
21
21
<Note>
22
-
React Compiler is currently in RC. Install it using the `@rc`tag to get the latest release candidate version.
22
+
کامپایلر ریاکت در حال حاضر در RC است. برای دریافت آخرین نسخه کاندید انتشار، از تگ `@rc`استفاده کنید.
23
23
</Note>
24
24
25
-
## Installation {/*installation*/}
25
+
## نصب {/*installation*/}
26
26
27
-
Install React Compiler as a `devDependency`:
27
+
کامپایلر ریاکت را به عنوان یک `devDependency` نصب کنید:
28
28
29
29
<TerminalBlock>
30
30
npm install -D babel-plugin-react-compiler@rc
31
31
</TerminalBlock>
32
32
33
-
Or with Yarn:
33
+
یا با Yarn:
34
34
35
35
<TerminalBlock>
36
36
yarn add -D babel-plugin-react-compiler@rc
37
37
</TerminalBlock>
38
38
39
-
Or with pnpm:
39
+
یا با pnpm:
40
40
41
41
<TerminalBlock>
42
42
pnpm install -D babel-plugin-react-compiler@rc
43
43
</TerminalBlock>
44
44
45
-
## Basic Setup {/*basic-setup*/}
45
+
## راهاندازی پایه {/*basic-setup*/}
46
46
47
-
React Compiler is designed to work by default without any configuration. However, if you need to configure it in special circumstances (for example, to target React versions below 19), refer to the [compiler options reference](/reference/react-compiler/configuration).
47
+
کامپایلر ریاکت بهطور پیشفرض بدون نیاز به هیچ تنظیماتی کار میکند. با این حال، اگر نیاز به پیکربندی آن در شرایط خاص دارید (برای مثال، برای هدفگذاری نسخههای ریاکت پایینتر از 19)، به [مرجع گزینههای کامپایلر](/reference/react-compiler/configuration) مراجعه کنید.
48
48
49
-
The setup process depends on your build tool. React Compiler includes a Babel plugin that integrates with your build pipeline.
49
+
فرآیند راهاندازی به ابزار ساخت شما بستگی دارد. کامپایلر ریاکت شامل یک پلاگین Babel است که با خط لوله ساخت شما یکپارچه میشود.
50
50
51
51
<Pitfall>
52
-
React Compiler must run **first**in your Babel plugin pipeline. The compiler needs the original source information for proper analysis, so it must process your code before other transformations.
52
+
کامپایلر ریاکت باید **ابتدا**در خط لوله پلاگین Babel شما اجرا شود. کامپایلر به اطلاعات منبع اصلی برای تحلیل صحیح نیاز دارد، بنابراین باید قبل از سایر تغییرات کد شما را پردازش کند.
53
53
</Pitfall>
54
54
55
-
### Babel {/*babel*/}
55
+
### بابل {/*babel*/}
56
56
57
-
Create or update your `babel.config.js`:
57
+
`babel.config.js` خود را ایجاد یا بهروزرسانی کنید:
58
58
59
59
```js {3}
60
60
module.exports= {
@@ -68,7 +68,7 @@ module.exports = {
68
68
69
69
### Vite {/*vite*/}
70
70
71
-
If you use Vite, you can add the plugin to vite-plugin-react:
71
+
اگر از Vite استفاده میکنید، میتوانید پلاگین را به vite-plugin-react اضافه کنید.
72
72
73
73
```js {3,9}
74
74
// vite.config.js
@@ -86,7 +86,7 @@ export default defineConfig({
86
86
});
87
87
```
88
88
89
-
Alternatively, if you prefer a separate Babel plugin for Vite:
89
+
بهطور جایگزین، اگر یک پلاگین Babel جداگانه برای Vite ترجیح میدهید:
A community webpack loader is [now available here](https://github.com/SukkaW/react-compiler-webpack).
150
+
یک لودر webpack جامعهمحور [اکنون اینجا در دسترس است](https://github.com/SukkaW/react-compiler-webpack).
151
151
152
152
### Expo {/*usage-with-expo*/}
153
153
154
-
Please refer to [Expo's docs](https://docs.expo.dev/guides/react-compiler/)to enable and use the React Compiler in Expo apps.
154
+
لطفاً به [مستندات Expo](https://docs.expo.dev/guides/react-compiler/)مراجعه کنید تا کامپایلر ریاکت را در اپلیکیشنهای Expo فعال کرده و استفاده کنید.
155
155
156
-
### Metro (React Native) {/*usage-with-react-native-metro*/}
156
+
### Metro (ریاکت نیتیو) {/*usage-with-react-native-metro*/}
157
157
158
-
React Native uses Babel via Metro, so refer to the [Usage with Babel](#babel)section for installation instructions.
158
+
ریاکت نیتیو از Babel از طریق Metro استفاده میکند، بنابراین برای دستورالعملهای نصب به بخش [Usage with Babel](#babel)مراجعه کنید.
159
159
160
160
### Rspack {/*usage-with-rspack*/}
161
161
162
-
Please refer to [Rspack's docs](https://rspack.dev/guide/tech/react#react-compiler)to enable and use the React Compiler in Rspack apps.
162
+
لطفاً به [مستندات Rspack](https://rspack.dev/guide/tech/react#react-compiler)مراجعه کنید تا کامپایلر ریاکت را در برنامههای Rspack فعال کرده و استفاده کنید.
163
163
164
164
### Rsbuild {/*usage-with-rsbuild*/}
165
165
166
-
Please refer to [Rsbuild's docs](https://rsbuild.dev/guide/framework/react#react-compiler)to enable and use the React Compiler in Rsbuild apps.
166
+
لطفاً به [مستندات Rsbuild](https://rsbuild.dev/guide/framework/react#react-compiler)مراجعه کنید تا کامپایلر ریاکت را در برنامههای Rsbuild فعال کرده و استفاده کنید.
167
167
168
168
169
-
## ESLint Integration {/*eslint-integration*/}
169
+
## یکپارچهسازی ESLint {/*eslint-integration*/}
170
170
171
-
React Compiler includes an ESLint rule that helps identify code that can't be optimized. When the ESLint rule reports an error, it means the compiler will skip optimizing that specific component or hook. This is safe: the compiler will continue optimizing other parts of your codebase. You don't need to fix all violations immediately. Address them at your own pace to gradually increase the number of optimized components.
171
+
کامپایلر ریاکت شامل یک قانون ESLint است که به شناسایی کدی که نمیتواند بهینهسازی شود کمک میکند. وقتی قانون ESLint خطایی گزارش میدهد، به این معنی است که کامپایلر از بهینهسازی آن کامپوننت یا هوک خاص صرفنظر خواهد کرد. این کار ایمن است: کامپایلر به بهینهسازی سایر بخشهای کد شما ادامه خواهد داد. نیازی نیست که بلافاصله همه تخلفات را برطرف کنید. با سرعت خودتان به آنها رسیدگی کنید تا بهتدریج تعداد کامپوننتهای بهینهشده را افزایش دهید.
172
172
173
-
Install the ESLint plugin:
173
+
پلاگین ESLint را نصب کنید:
174
174
175
175
<TerminalBlock>
176
176
npm install -D eslint-plugin-react-hooks@rc
177
177
</TerminalBlock>
178
178
179
-
If you haven't already configured eslint-plugin-react-hooks, follow the [installation instructions in the readme](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md#installation). The compiler rule is enabled by default in the latest RC, so no additional configuration is needed.
179
+
اگر هنوز eslint-plugin-react-hooks را پیکربندی نکردهاید، [دستورالعملهای نصب در readme](https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md#installation) را دنبال کنید. قانون کامپایلر بهطور پیشفرض در آخرین نسخه RC فعال است، بنابراین نیازی به پیکربندی اضافی نیست.
180
180
181
-
The ESLint rule will:
182
-
-Identify violations of the [Rules of React](/reference/rules)
183
-
-Show which components can't be optimized
184
-
-Provide helpful error messages for fixing issues
181
+
قانون ESLint به این صورت عمل خواهد کرد:
182
+
-تخلفات از [قوانین ریاکت](/reference/rules) را شناسایی کنید
183
+
-نشان دهید کدام کامپوننتها نمیتوانند بهینه شوند
184
+
-پیامهای خطای مفیدی برای رفع مشکلات فراهم کنید
185
185
186
-
## Verify Your Setup {/*verify-your-setup*/}
186
+
## تنظیمات خود را تأیید کنید {/*verify-your-setup*/}
187
187
188
-
After installation, verify that React Compiler is working correctly.
188
+
پس از نصب، اطمینان حاصل کنید که کامپایلر React به درستی کار میکند.
4.به دنبال ایموجی ✨ در کنار نام کامپوننتها بگردید.
198
198
199
-
If the compiler is working:
200
-
-Components will show a "Memo ✨" badge in React DevTools
201
-
-Expensive calculations will be automatically memoized
202
-
-No manual`useMemo`is required
199
+
اگر کامپایلر در حال کار است:
200
+
-کامپوننتها در React DevTools نشان "Memo ✨" را نمایش خواهند داد.
201
+
-محاسبات پرهزینه بهطور خودکار بهخاطر سپرده میشوند.
202
+
-نیازی به`useMemo`بهصورت دستی نیست
203
203
204
-
### Check Build Output {/*check-build-output*/}
204
+
### بررسی خروجی بیلد {/*check-build-output*/}
205
205
206
-
You can also verify the compiler is running by checking your build output. The compiled code will include automatic memoization logic that the compiler adds automatically.
206
+
شما همچنین میتوانید با بررسی خروجی بیلد، اطمینان حاصل کنید که کامپایلر در حال اجرا است. کد کامپایلشده شامل منطق memoization خودکار خواهد بود که کامپایلر بهطور خودکار اضافه میکند.
207
207
208
208
```js
209
209
import { cas_c } from"react/compiler-runtime";
@@ -221,11 +221,11 @@ export default function MyApp() {
221
221
222
222
```
223
223
224
-
## Troubleshooting {/*troubleshooting*/}
224
+
## عیبیابی {/*troubleshooting*/}
225
225
226
-
### Opting out specific components {/*opting-out-specific-components*/}
226
+
### انصراف از کامپوننتهای خاص {/*opting-out-specific-components*/}
227
227
228
-
If a component is causing issues after compilation, you can temporarily opt it out using the `"use no memo"`directive:
228
+
اگر یک کامپوننت پس از کامپایل باعث ایجاد مشکلاتی میشود، میتوانید بهطور موقت آن را با استفاده از دستور `"use no memo"`غیرفعال کنید:
229
229
230
230
```js
231
231
functionProblematicComponent() {
@@ -234,16 +234,16 @@ function ProblematicComponent() {
234
234
}
235
235
```
236
236
237
-
This tells the compiler to skip optimization for this specific component. You should fix the underlying issue and remove the directive once resolved.
237
+
این به کامپایلر میگوید که بهینهسازی را برای این کامپوننت خاص نادیده بگیرد. شما باید مشکل اصلی را برطرف کنید و پس از حل آن، این دستور را حذف کنید.
238
238
239
-
For more troubleshooting help, see the [debugging guide](/learn/react-compiler/debugging).
239
+
برای کمک بیشتر در رفع اشکال، به [راهنمای اشکالزدایی](/learn/react-compiler/debugging) مراجعه کنید.
240
240
241
-
## Next Steps {/*next-steps*/}
241
+
## مراحل بعدی {/*next-steps*/}
242
242
243
-
Now that you have React Compiler installed, learn more about:
243
+
حالا که کامپایلر ریاکت را نصب کردهاید، بیشتر بیاموزید دربارهٔ:
244
244
245
-
-[React version compatibility](/reference/react-compiler/target)for React 17 and 18
246
-
-[Configuration options](/reference/react-compiler/configuration)to customize the compiler
0 commit comments