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
> `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).
12
12
>
13
-
>We provide [a codemod script](/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactproptypes)to automate the conversion.
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` :
16
16
17
17
```javascript
18
18
importPropTypesfrom'prop-types';
@@ -30,11 +30,11 @@ Greeting.propTypes = {
30
30
};
31
31
```
32
32
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).
34
34
35
35
### PropTypes {#proptypes}
36
36
37
-
Here is an example documenting the different validators provided:
37
+
فيما يلي مثال يوضح مختلف أدوات التحقق المتوفرة:
38
38
39
39
```javascript
40
40
importPropTypesfrom'prop-types';
@@ -119,9 +119,9 @@ MyComponent.propTypes = {
119
119
};
120
120
```
121
121
122
-
### Requiring Single Child {#requiring-single-child}
You can define default values for your `props`by assigning to the special `defaultProps`property:
148
+
يمكنك تحديد القيم الافتراضية للخاصيات `props`بتعيين خاصية `defaultProps` :
149
149
150
150
```javascript
151
151
classGreetingextendsReact.Component {
@@ -168,7 +168,7 @@ ReactDOM.render(
168
168
);
169
169
```
170
170
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).
172
172
173
173
```javascript
174
174
classGreetingextendsReact.Component {
@@ -184,4 +184,4 @@ class Greeting extends React.Component {
184
184
}
185
185
```
186
186
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