Skip to content

Commit d77652d

Browse files
committed
Translating typechecking-with-proptypes.md
1 parent 1f76593 commit d77652d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

content/docs/typechecking-with-proptypes.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ redirect_from:
66
- "docs/react-api.html#typechecking-with-proptypes"
77
---
88

9-
> Note:
9+
> تنبيه :
1010
>
11-
> `React.PropTypes` has moved into a different package since React v15.5. Please use [the `prop-types` library instead](https://www.npmjs.com/package/prop-types).
11+
> `React.PropTypes` انتقلت إلى حزمة مختلفة منذ React v15.5. من فضلك استخدم [مكتبة `prop-types` عوضا](https://www.npmjs.com/package/prop-types).
1212
>
13-
>We provide [a codemod script](/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactproptypes) to automate the conversion.
13+
> نحن نوفر [ سكريبت (script) ](/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactproptypes) لتسهيل الإنتقال.
1414
15-
As your app grows, you can catch a lot of bugs with typechecking. For some applications, you can use JavaScript extensions like [Flow](https://flow.org/) or [TypeScript](https://www.typescriptlang.org/) to typecheck your whole application. But even if you don't use those, React has some built-in typechecking abilities. To run typechecking on the props for a component, you can assign the special `propTypes` property:
15+
بينما يصير تطبيقك اكثر توسعا ، يمكنك تفادي الكثير من الأخطاء من خلال التحقق من الأنواع. بالنسبة لبعض التطبيقات ، يمكنك استخدام ملحقات JavaScript مثل [Flow](https://flow.org/) أو [TypeScript](https://www.typescriptlang.org/) للتحقق من الأنواع . ولكن حتى لو كنت لا تستخدم هذه الملحقات , React لديه بعض الإضافات المدمجة التي لديها القدرة على التحقق من الأنواع . لتشغيل التحقق من الأنواع على الخاصيات (props) لمكوّن (Component) , يمكنك تعيين خاصية `propTypes` :
1616

1717
```javascript
1818
import PropTypes from 'prop-types';
@@ -30,11 +30,11 @@ Greeting.propTypes = {
3030
};
3131
```
3232

33-
`PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. In this example, we're using `PropTypes.string`. When an invalid value is provided for a prop, a warning will be shown in the JavaScript console. For performance reasons, `propTypes` is only checked in development mode.
33+
`PropTypes` يصدر مجموعة من أدوات التحقق التي يمكن استخدامها للتأكد من صحة البيانات التي تتلقاها. في هذا المثال نحن نستعمل `PropTypes.string`. عندما يتم توفير قيمة غير مقبولة لخاصية (props) ,سيظهر تحذير في وحدة التحكم (JavaScript Console). لأسباب تتعلق بأداء التطبيق , يتم التحقق من `propTypes` في وضع التطوير فقط (Development mode).
3434

3535
### PropTypes {#proptypes}
3636

37-
Here is an example documenting the different validators provided:
37+
فيما يلي مثال يوضح مختلف أدوات التحقق المتوفرة:
3838

3939
```javascript
4040
import PropTypes from 'prop-types';
@@ -119,9 +119,9 @@ MyComponent.propTypes = {
119119
};
120120
```
121121

122-
### Requiring Single Child {#requiring-single-child}
122+
### استلزام مكون بنوي وحيد {#requiring-single-child}
123123

124-
With `PropTypes.element` you can specify that only a single child can be passed to a component as children.
124+
بإستخدام `PropTypes.element` يمكنك تحديد أنه يمكن فقط نقل مكون وحيد إلى أحد المكونات كمكونات بنيوية.
125125

126126
```javascript
127127
import PropTypes from 'prop-types';
@@ -143,9 +143,9 @@ MyComponent.propTypes = {
143143
};
144144
```
145145

146-
### Default Prop Values {#default-prop-values}
146+
### قيم الخاصيات الإفتراضية {#default-prop-values}
147147

148-
You can define default values for your `props` by assigning to the special `defaultProps` property:
148+
يمكنك تحديد القيم الافتراضية للخاصيات `props` بتعيين خاصية `defaultProps` :
149149

150150
```javascript
151151
class Greeting extends React.Component {
@@ -168,7 +168,7 @@ ReactDOM.render(
168168
);
169169
```
170170

171-
If you are using a Babel transform like [transform-class-properties](https://babeljs.io/docs/plugins/transform-class-properties/) , you can also declare `defaultProps` as static property within a React component class. This syntax has not yet been finalized though and will require a compilation step to work within a browser. For more information, see the [class fields proposal](https://github.com/tc39/proposal-class-fields).
171+
إذا كنت تستخدم تحويلات Babel مثل [transform-class-properties](https://babeljs.io/docs/plugins/transform-class-properties/) , يمكنك أيضا تعيين `defaultProps` كخاصية ثابتة داخل صنف (class) مكون React . هذه الشفرة البرمجية لم يتم الإنتهاء منها بعد و ستتطلب خطوة التحويل البرمجي (Compilation) للعمل داخل المتصفح . للمزيد من المعلومات ، أنظر الى [class fields proposal](https://github.com/tc39/proposal-class-fields).
172172

173173
```javascript
174174
class Greeting extends React.Component {
@@ -184,4 +184,4 @@ class Greeting extends React.Component {
184184
}
185185
```
186186

187-
The `defaultProps` will be used to ensure that `this.props.name` will have a value if it was not specified by the parent component. The `propTypes` typechecking happens after `defaultProps` are resolved, so typechecking will also apply to the `defaultProps`.
187+
تُستخدم `defaultProps` للتحقق من أن `this.props.name` سيكون لها قيمة إذا لم يتم تحديدها بواسطة المكون الأب . التحقق من الأنواع بإستخدام `propTypes` يحدث بعد تعيين قيمة لـ `defaultProps`, ولهذا التحقق من الأنواع ستنطبق على `defaultProps` ايضا .

0 commit comments

Comments
 (0)