diff --git a/content/docs/jsx-in-depth.md b/content/docs/jsx-in-depth.md index 3dcf2ac26..a469f9eee 100644 --- a/content/docs/jsx-in-depth.md +++ b/content/docs/jsx-in-depth.md @@ -1,6 +1,6 @@ --- id: jsx-in-depth -title: JSX In Depth +title: شرح JSX بالتفصيل permalink: docs/jsx-in-depth.html redirect_from: - "docs/jsx-spread.html" @@ -13,31 +13,32 @@ redirect_from: - "docs/jsx-in-depth-ko-KR.html" --- -Fundamentally, JSX just provides syntactic sugar for the `React.createElement(component, props, ...children)` function. The JSX code: +توفِّر JSX علينا عناء إنشاء العناصر بإستخدام الدالة `React.createElement(component, props, ...children)`. انظر إلى الشيفرة التالية في JSX: + ```js - Click Me + انقر هنا ``` -compiles into: +تُترجَم الشيفرة السّابقة إلى: ```js React.createElement( MyButton, {color: 'blue', shadowSize: 2}, - 'Click Me' + 'انقر هنا' ) ``` -You can also use the self-closing form of the tag if there are no children. So: +بإمكانك أيضًا استخدام الشكل ذاتي الإغلاق للعنصر إن كان لا يحتوي على أيّة عناصر أبناء: ```js
``` -compiles into: +تُترجَم الشيفرة السّابقة إلى: ```js React.createElement( @@ -47,19 +48,19 @@ React.createElement( ) ``` -If you want to test out how some specific JSX is converted into JavaScript, you can try out [the online Babel compiler](babel://jsx-simple-example). +إن أردتَ اختبار كيفيّة تحويل بعض شيفرات JSX إلى JavaScript فبإمكانك تجريب [مُترجِم Babel على الإنترنت](babel://jsx-simple-example). -## Specifying The React Element Type {#specifying-the-react-element-type} +## تحديد نوع عنصر React {#specifying-the-react-element-type} -The first part of a JSX tag determines the type of the React element. +يُحدِّد الحرف الأول في وسم JSX نوعَ عنصر React. -Capitalized types indicate that the JSX tag is referring to a React component. These tags get compiled into a direct reference to the named variable, so if you use the JSX `` expression, `Foo` must be in scope. +تُشير الأنواع التي تبدأ بحرف كبيرة (Capitalized types) إلى أنّ العنصر المذكور هو مُكوِّن React. تُترجَم هذه العناصر إلى مرجع مباشر إلى المتغيّر الذي يحمل اسمها، لذا إن استخدمت التعبير ‎``‎ في JSX يجب أن يكون المتغيّر `Foo` في نفس المجال. -### React Must Be in Scope {#react-must-be-in-scope} +### يجب على React أن تكون في نفس المجال {#react-must-be-in-scope} -Since JSX compiles into calls to `React.createElement`, the `React` library must also always be in scope from your JSX code. +لمّا كانت JSX تُترجَم إلى نداءات للتابع `React.createElement`، فيجب على مكتبة `React` أن تكون في نفس المجال الذي تكون فيه شيفرة JSX. -For example, both of the imports are necessary in this code, even though `React` and `CustomButton` are not directly referenced from JavaScript: +على سبيل المثال الاستيراد التالي ضروري في هذه الشّيفرة على الرغم من أنّ `React` و `CustomButton` لا يُشار إليهما بشكل مباشر من JavaScript: ```js{1,2,5} import React from 'react'; @@ -71,18 +72,18 @@ function WarningButton() { } ``` -If you don't use a JavaScript bundler and loaded React from a `