Skip to content

Commit 6d111b4

Browse files
docs(ar): translate React Compiler reference, performance tracks, community videos
Made-with: Cursor
1 parent 0def3fb commit 6d111b4

12 files changed

Lines changed: 566 additions & 568 deletions

File tree

src/content/community/videos.md

Lines changed: 78 additions & 78 deletions
Large diffs are not rendered by default.

src/content/reference/dev-tools/react-performance-tracks.md

Lines changed: 74 additions & 74 deletions
Large diffs are not rendered by default.

src/content/reference/react-compiler/compilationMode.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,109 +4,109 @@ title: compilationMode
44

55
<Intro>
66

7-
The `compilationMode` option controls how the React Compiler selects which functions to compile.
7+
يتحكم خيار `compilationMode` في كيفية اختيار React Compiler للدوال التي يُجمّعها.
88

99
</Intro>
1010

1111
```js
1212
{
13-
compilationMode: 'infer' // or 'annotation', 'syntax', 'all'
13+
compilationMode: 'infer' // أو 'annotation' أو 'syntax' أو 'all'
1414
}
1515
```
1616

1717
<InlineToc />
1818

1919
---
2020

21-
## Reference {/*reference*/}
21+
## المرجع {/*reference*/}
2222

2323
### `compilationMode` {/*compilationmode*/}
2424

25-
Controls the strategy for determining which functions the React Compiler will optimize.
25+
يحدد الاستراتيجية لمعرفة أي الدوال سيُحسِّنها React Compiler.
2626

27-
#### Type {/*type*/}
27+
#### النوع {/*type*/}
2828

2929
```
3030
'infer' | 'syntax' | 'annotation' | 'all'
3131
```
3232

33-
#### Default value {/*default-value*/}
33+
#### القيمة الافتراضية {/*default-value*/}
3434

3535
`'infer'`
3636

37-
#### Options {/*options*/}
37+
#### الخيارات {/*options*/}
3838

39-
- **`'infer'`** (default): The compiler uses intelligent heuristics to identify React components and hooks:
40-
- Functions explicitly annotated with `"use memo"` directive
41-
- Functions that are named like components (PascalCase) or hooks (`use` prefix) AND create JSX and/or call other hooks
39+
- **`'infer'`** (الافتراضي): يستخدم المُصرّف استدلالاً لتحديد مكوّنات React وhooks:
40+
- دوال موسومة صراحة بتوجيه `"use memo"`
41+
- دوال تُسمّى كمكوّنات (PascalCase) أو hooks (بادئة `use`) **وتُنشئ JSX** و/أو **تستدعي hooks أخرى**
4242

43-
- **`'annotation'`**: Only compile functions explicitly marked with the `"use memo"` directive. Ideal for incremental adoption.
43+
- **`'annotation'`**: يُجمّع فقط الدوال الموسومة بتوجيه `"use memo"`. مناسب للتبنّي التدريجي.
4444

45-
- **`'syntax'`**: Only compile components and hooks that use Flow's [component](https://flow.org/en/docs/react/component-syntax/) and [hook](https://flow.org/en/docs/react/hook-syntax/) syntax.
45+
- **`'syntax'`**: يُجمّع فقط المكوّنات والـ hooks التي تستخدم صياغة Flow لـ [component](https://flow.org/en/docs/react/component-syntax/) و[hook](https://flow.org/en/docs/react/hook-syntax/).
4646

47-
- **`'all'`**: Compile all top-level functions. Not recommended as it may compile non-React functions.
47+
- **`'all'`**: يُجمّع كل الدوال على المستوى الأعلى. غير موصى به لأنه قد يُجمّع دوالاً ليست من React.
4848

49-
#### Caveats {/*caveats*/}
49+
#### ملاحظات {/*caveats*/}
5050

51-
- The `'infer'` mode requires functions to follow React naming conventions to be detected
52-
- Using `'all'` mode may negatively impact performance by compiling utility functions
53-
- The `'syntax'` mode requires Flow and won't work with TypeScript
54-
- Regardless of mode, functions with `"use no memo"` directive are always skipped
51+
- وضع `'infer'` يتطلّب تسمية تتبع اصطلاحات React ليُكتشف المكوّن
52+
- وضع `'all'` قد يضرّ بالأداء بتجميع دوال مساعدة
53+
- وضع `'syntax'` يتطلّب Flow ولا يعمل مع TypeScript
54+
- بغض النظر عن الوضع، الدوال التي تحتوي `"use no memo"` تُستبعد دائماً
5555

5656
---
5757

58-
## Usage {/*usage*/}
58+
## الاستخدام {/*usage*/}
5959

60-
### Default inference mode {/*default-inference-mode*/}
60+
### وضع الاستنتاج الافتراضي {/*default-inference-mode*/}
6161

62-
The default `'infer'` mode works well for most codebases that follow React conventions:
62+
وضع `'infer'` الافتراضي يناسب أغلب القواعد التي تتبع اصطلاحات React:
6363

6464
```js
6565
{
6666
compilationMode: 'infer'
6767
}
6868
```
6969

70-
With this mode, these functions will be compiled:
70+
في هذا الوضع تُجمَّع أمثلة مثل:
7171

7272
```js
73-
//Compiled: Named like a component + returns JSX
73+
//يُجمَّع: اسم كمكوّن + يعيد JSX
7474
function Button(props) {
7575
return <button>{props.label}</button>;
7676
}
7777

78-
//Compiled: Named like a hook + calls hooks
78+
//يُجمَّع: اسم كـ hook + يستدعي hooks
7979
function useCounter() {
8080
const [count, setCount] = useState(0);
8181
return [count, setCount];
8282
}
8383

84-
//Compiled: Explicit directive
84+
//يُجمَّع: توجيه صريح
8585
function expensiveCalculation(data) {
8686
"use memo";
8787
return data.reduce(/* ... */);
8888
}
8989

90-
//Not compiled: Not a component/hook pattern
90+
//لا يُجمَّع: ليس نمط مكوّن/hook
9191
function calculateTotal(items) {
9292
return items.reduce((a, b) => a + b, 0);
9393
}
9494
```
9595

96-
### Incremental adoption with annotation mode {/*incremental-adoption*/}
96+
### تبنّي تدريجي بوضع annotation {/*incremental-adoption*/}
9797

98-
For gradual migration, use `'annotation'` mode to only compile marked functions:
98+
للهجرة التدريجية استخدم `'annotation'` لتجميع الدوال الموسومة فقط:
9999

100100
```js
101101
{
102102
compilationMode: 'annotation'
103103
}
104104
```
105105

106-
Then explicitly mark functions to compile:
106+
ثم علّم الدوال يدوياً:
107107

108108
```js
109-
// Only this function will be compiled
109+
// هذه الدالة فقط تُجمَّع
110110
function ExpensiveList(props) {
111111
"use memo";
112112
return (
@@ -118,51 +118,51 @@ function ExpensiveList(props) {
118118
);
119119
}
120120

121-
// This won't be compiled without the directive
121+
// بدون التوجيه لا تُجمَّع
122122
function NormalComponent(props) {
123123
return <div>{props.content}</div>;
124124
}
125125
```
126126

127-
### Using Flow syntax mode {/*flow-syntax-mode*/}
127+
### وضع صياغة Flow {/*flow-syntax-mode*/}
128128

129-
If your codebase uses Flow instead of TypeScript:
129+
إذا كانت قاعدتك تستخدم Flow بدل TypeScript:
130130

131131
```js
132132
{
133133
compilationMode: 'syntax'
134134
}
135135
```
136136

137-
Then use Flow's component syntax:
137+
ثم استخدم صياغة مكوّنات Flow:
138138

139139
```js
140-
// Compiled: Flow component syntax
140+
// يُجمَّع: صياغة مكوّن Flow
141141
component Button(label: string) {
142142
return <button>{label}</button>;
143143
}
144144

145-
// Compiled: Flow hook syntax
145+
// يُجمَّع: صياغة hook في Flow
146146
hook useCounter(initial: number) {
147147
const [count, setCount] = useState(initial);
148148
return [count, setCount];
149149
}
150150

151-
// Not compiled: Regular function syntax
151+
// لا يُجمَّع: دالة عادية
152152
function helper(data) {
153153
return process(data);
154154
}
155155
```
156156

157-
### Opting out specific functions {/*opting-out*/}
157+
### استبعاد دوال محدّدة {/*opting-out*/}
158158

159-
Regardless of compilation mode, use `"use no memo"` to skip compilation:
159+
بغض النظر عن وضع التجميع، استخدم `"use no memo"` لتخطّي التجميع:
160160

161161
```js
162162
function ComponentWithSideEffects() {
163-
"use no memo"; // Prevent compilation
163+
"use no memo"; // منع التجميع
164164

165-
// This component has side effects that shouldn't be memoized
165+
// هذا المكوّن له تأثيرات جانبية لا يجب تذكّرها
166166
logToAnalytics('component_rendered');
167167

168168
return <div>Content</div>;
@@ -171,29 +171,29 @@ function ComponentWithSideEffects() {
171171

172172
---
173173

174-
## Troubleshooting {/*troubleshooting*/}
174+
## استكشاف الأعطال {/*troubleshooting*/}
175175

176-
### Component not being compiled in infer mode {/*component-not-compiled-infer*/}
176+
### المكوّن لا يُجمَّع في وضع infer {/*component-not-compiled-infer*/}
177177

178-
In `'infer'` mode, ensure your component follows React conventions:
178+
في `'infer'` تأكد من اصطلاحات React:
179179

180180
```js
181-
//Won't be compiled: lowercase name
181+
//لن يُجمَّع: اسم بحروف صغيرة
182182
function button(props) {
183183
return <button>{props.label}</button>;
184184
}
185185

186-
//Will be compiled: PascalCase name
186+
//سيُجمَّع: PascalCase
187187
function Button(props) {
188188
return <button>{props.label}</button>;
189189
}
190190

191-
//Won't be compiled: doesn't create JSX or call hooks
191+
//لن يُجمَّع: لا ينشئ JSX ولا يستدعي hooks
192192
function useData() {
193193
return window.localStorage.getItem('data');
194194
}
195195

196-
//Will be compiled: calls a hook
196+
//سيُجمَّع: يستدعي hook
197197
function useData() {
198198
const [data] = useState(() => window.localStorage.getItem('data'));
199199
return data;
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
---
2-
title: Compiling Libraries
2+
title: تجميع المكتبات
33
---
44

55
<Intro>
6-
This guide helps library authors understand how to use React Compiler to ship optimized library code to their users.
6+
يساعدك هذا الدليل كمؤلف مكتبة على استخدام React Compiler لنشر شيفرة مكتبتك مُحسَّنة لمستخدميك.
77
</Intro>
88

99
<InlineToc />
1010

11-
## Why Ship Compiled Code? {/*why-ship-compiled-code*/}
11+
## لماذا تنشر شيفرة مُجمَّعة؟ {/*why-ship-compiled-code*/}
1212

13-
As a library author, you can compile your library code before publishing to npm. This provides several benefits:
13+
كمؤلف مكتبة يمكنك تجميع شيفرة المكتبة قبل النشر إلى npm. الفوائد تشمل:
1414

15-
- **Performance improvements for all users** - Your library users get optimized code even if they aren't using React Compiler yet
16-
- **No configuration required by users** - The optimizations work out of the box
17-
- **Consistent behavior** - All users get the same optimized version regardless of their build setup
15+
- **تحسين الأداء لجميع المستخدمين** — يحصل مستخدمو مكتبتك على شيفرة مُحسَّنة حتى إن لم يفعّلوا React Compiler بعد
16+
- **لا إعداد مطلوب من المستخدمين** — التحسينات تعمل مباشرة
17+
- **سلوك متسق** — كل المستخدمون يحصلون على النسخة المُحسَّنة بغض النظر عن إعداد البناء
1818

19-
## Setting Up Compilation {/*setting-up-compilation*/}
19+
## إعداد التجميع {/*setting-up-compilation*/}
2020

21-
Add React Compiler to your library's build process:
21+
أضف React Compiler إلى عملية بناء مكتبتك:
2222

2323
<TerminalBlock>
2424
npm install -D babel-plugin-react-compiler@latest
2525
</TerminalBlock>
2626

27-
Configure your build tool to compile your library. For example, with Babel:
27+
اضبط أداة البناء لتجميع المكتبة. مثال مع Babel:
2828

2929
```js
3030
// babel.config.js
3131
module.exports = {
3232
plugins: [
3333
'babel-plugin-react-compiler',
3434
],
35-
// ... other config
35+
// ... إعداد آخر
3636
};
3737
```
3838

39-
## Backwards Compatibility {/*backwards-compatibility*/}
39+
## التوافق مع الإصدارات السابقة {/*backwards-compatibility*/}
4040

41-
If your library supports React versions below 19, you'll need additional configuration:
41+
إذا كانت مكتبتك تدعم إصدارات React أقل من 19، ستحتاج إعداداً إضافياً:
4242

43-
### 1. Install the runtime package {/*install-runtime-package*/}
43+
### 1. تثبيت حزمة التشغيل {/*install-runtime-package*/}
4444

45-
We recommend installing react-compiler-runtime as a direct dependency:
45+
نوصي بتثبيت `react-compiler-runtime` كتبعية مباشرة:
4646

4747
<TerminalBlock>
4848
npm install react-compiler-runtime@latest
@@ -59,48 +59,48 @@ npm install react-compiler-runtime@latest
5959
}
6060
```
6161

62-
### 2. Configure the target version {/*configure-target-version*/}
62+
### 2. ضبط إصدار الاستهداف {/*configure-target-version*/}
6363

64-
Set the minimum React version your library supports:
64+
عيّن أقل إصدار React تدعمه المكتبة:
6565

6666
```js
6767
{
68-
target: '17', // Minimum supported React version
68+
target: '17', // أقل إصدار React مدعوم
6969
}
7070
```
7171

72-
## Testing Strategy {/*testing-strategy*/}
72+
## استراتيجية الاختبار {/*testing-strategy*/}
7373

74-
Test your library both with and without compilation to ensure compatibility. Run your existing test suite against the compiled code, and also create a separate test configuration that bypasses the compiler. This helps catch any issues that might arise from the compilation process and ensures your library works correctly in all scenarios.
74+
اختبر مكتبتك مع التجميع وبدونه لضمان التوافق. شغّل مجموعة الاختبارات الحالية على الشيفرة المُجمَّعة، وأنشئ إعداد اختبار منفصلاً يتخطّى المُصرّف. يساعد ذلك على اكتشاف مشاكل قد تنشأ عن التجميع ويضمن عمل المكتبة في كل السيناريوهات.
7575

76-
## Troubleshooting {/*troubleshooting*/}
76+
## استكشاف الأعطال {/*troubleshooting*/}
7777

78-
### Library doesn't work with older React versions {/*library-doesnt-work-with-older-react-versions*/}
78+
### المكتبة لا تعمل مع React أقدم {/*library-doesnt-work-with-older-react-versions*/}
7979

80-
If your compiled library throws errors in React 17 or 18:
80+
إذا رمت المكتبة المُجمَّعة أخطاء في React 17 أو 18:
8181

82-
1. Verify you've installed `react-compiler-runtime` as a dependency
83-
2. Check that your `target` configuration matches your minimum supported React version
84-
3. Ensure the runtime package is included in your published bundle
82+
1. تحقق من تثبيت `react-compiler-runtime` كتبعية
83+
2. تأكد أن إعداد `target` يطابق أقل إصدار React تدعمه
84+
3. تأكد من تضمين حزمة التشغيل في الحزمة المنشورة
8585

86-
### Compilation conflicts with other Babel plugins {/*compilation-conflicts-with-other-babel-plugins*/}
86+
### تعارض التجميع مع إضافات Babel أخرى {/*compilation-conflicts-with-other-babel-plugins*/}
8787

88-
Some Babel plugins may conflict with React Compiler:
88+
قد تتعارض بعض إضافات Babel مع React Compiler:
8989

90-
1. Place `babel-plugin-react-compiler` early in your plugin list
91-
2. Disable conflicting optimizations in other plugins
92-
3. Test your build output thoroughly
90+
1. ضع `babel-plugin-react-compiler` مبكراً في قائمة الإضافات
91+
2. عطّل تحسينات متعارضة في إضافات أخرى
92+
3. اختبر مخرجات البناء بدقة
9393

94-
### Runtime module not found {/*runtime-module-not-found*/}
94+
### وحدة التشغيل غير موجودة {/*runtime-module-not-found*/}
9595

96-
If users see "Cannot find module 'react-compiler-runtime'":
96+
إذا رأى المستخدمون «Cannot find module 'react-compiler-runtime'»:
9797

98-
1. Ensure the runtime is listed in `dependencies`, not `devDependencies`
99-
2. Check that your bundler includes the runtime in the output
100-
3. Verify the package is published to npm with your library
98+
1. تأكد أن التشغيل في `dependencies` وليس `devDependencies`
99+
2. تحقق أن المُجمّع يضمّن التشغيل في المخرجات
100+
3. تأكد أن الحزمة منشورة على npm مع مكتبتك
101101

102-
## Next Steps {/*next-steps*/}
102+
## الخطوات التالية {/*next-steps*/}
103103

104-
- Learn about [debugging techniques](/learn/react-compiler/debugging) for compiled code
105-
- Check the [configuration options](/reference/react-compiler/configuration) for all compiler options
106-
- Explore [compilation modes](/reference/react-compiler/compilationMode) for selective optimization
104+
- تعرّف على [تقنيات التصحيح](/learn/react-compiler/debugging) للشيفرة المُجمَّعة
105+
- راجع [خيارات الإعداد](/reference/react-compiler/configuration) لكل خيارات المُصرّف
106+
- استكشف [أوضاع التجميع](/reference/react-compiler/compilationMode) للتحسين الانتقائي

0 commit comments

Comments
 (0)