Files
freeCodeCamp/guide/arabic/react/component/index.md
Randell Dawson d6a160445e Convert single backtick code sections to triple backtick code sections for Arabic Guide articles (13 of 15) (#36240)
* fix: converted single to triple backticks13

* fix: added prefix

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: removed language in wrong place

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: add language postfix

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>

* fix: removed language in wrong place

Co-Authored-By: Tom <20648924+moT01@users.noreply.github.com>
2019-06-20 18:07:24 -05:00

75 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: React - Components
localeTitle: رد الفعل - مكونات
---
## رد الفعل - مكونات
مكونات قابلة لإعادة الاستخدام في react.js. يمكنك ضخ القيمة في الدعائم كما هو موضح أدناه:
```jsx
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
const element = <Welcome name="Faisal Arkan" />;
ReactDOM.render(
element,
document.getElementById('root')
);
```
`name="Faisal Arkan"` سيعطي قيمة في `{props.name}` من `function Welcome(props)` `{props.name}` المكونة التي أعطيت القيمة `name="Faisal Arkan"` ، بعد أن تتفاعل ستجعل العنصر في html.
### طرق أخرى لإعلان المكونات
هناك العديد من الطرق لاعلان المكونات عند استخدام React.js، ولكن هناك نوعان من المكونات، ومكونات **_عديمي الجنسية_** ومكونات **_جليل._**
### جليل
#### مكونات نوع الطبقة
```jsx
class Cat extends React.Component {
constructor(props) {
super(props);
this.state = {
humor: 'happy'
}
}
render() {
return(
<div>
<h1>{this.props.name}</h1>
<p>
{this.props.color}
</p>
</div>
);
}
}
```
### مكونات عديمة الحالة
#### مكونات وظيفية (وظيفة السهم من ES6)
`const Cat = props => {
return (
<div>
<h1>{props.name}</h1>
<p>{props.color}</p>
</div>;
);
};
`
#### مكونات العودة الضمنية
```jsx
const Cat = props =>
<div>
<h1>{props.name}</h1>
<p>{props.color}</p>
</div>;
```