--- id: 5a24c314108439a4d403617b title: Pass a Callback as Props challengeType: 6 isRequired: false videoUrl: '' localeTitle: '' --- ## Description
يمكنك تمرير state كدعائم إلى مكونات state ، ولكنك لا تقتصر على تمرير البيانات. يمكنك أيضًا تمرير وظائف معالج أو أي طريقة يتم تعريفها في مكون React إلى مكون فرعي. هذه هي الطريقة التي تسمح للمكونات الفرعية بالتفاعل مع المكونات الأساسية الخاصة بها. تمر الطرق لطفل مثل الدعامة العادية. يتم تعيين اسم له ولديك إمكانية الوصول إلى اسم هذا الأسلوب ضمن this.props في المكون التابع.
## Instructions undefined ## Tests
```yml tests: - text: يجب أن يتم عرض مكون MyApp . testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(MyApp)); return mockedComponent.find("MyApp").length === 1; })(), "The MyApp component should render.");' - text: يجب أن يتم تقديم المكون GetInput . testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(MyApp)); return mockedComponent.find("GetInput").length === 1; })(), "The GetInput component should render.");' - text: '' testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(MyApp)); return mockedComponent.find("RenderInput").length === 1; })(), "The RenderInput component should render.");' - text: يجب أن يتلقى المكون GetInput خاصية حالة حالة MyApp inputValue ويحتوي على عنصر input بتعديل حالة MyApp . testString: 'async () => { const waitForIt = (fn) => new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 250)); const mockedComponent = Enzyme.mount(React.createElement(MyApp)); const state_1 = () => { mockedComponent.setState({inputValue: ""}); return waitForIt(() => mockedComponent.state() )}; const state_2 = () => { mockedComponent.find("input").simulate("change", {target: {value: "TestInput"}}); return waitForIt(() => mockedComponent.state() )}; const updated_1 = await state_1(); const updated_2 = await state_2(); assert(updated_1.inputValue === "" && updated_2.inputValue === "TestInput", "The GetInput component should receive the MyApp state property inputValue as props and contain an input element which modifies MyApp state."); }; ' - text: و RenderInput ينبغي أن يتلقى المكون MyApp ممتلكات الدولة inputValue كما الدعائم. testString: 'async () => { const waitForIt = (fn) => new Promise((resolve, reject) => setTimeout(() => resolve(fn()), 250)); const mockedComponent = Enzyme.mount(React.createElement(MyApp)); const state_1 = () => { mockedComponent.setState({inputValue: "TestName"}); return waitForIt(() => mockedComponent )}; const updated_1 = await state_1(); assert(updated_1.find("p").text().includes("TestName"), "The RenderInput component should receive the MyApp state property inputValue as props."); }; ' ```
## Challenge Seed
```jsx class MyApp extends React.Component { constructor(props) { super(props); this.state = { inputValue: " } this.handleChange = this.handleChange.bind(this); } handleChange(event) { this.setState({ inputValue: event.target.value }); } render() { return (
{ /* change code below this line */ } { /* change code above this line */ }
); } }; class GetInput extends React.Component { constructor(props) { super(props); } render() { return (

Get Input:

); } }; class RenderInput extends React.Component { constructor(props) { super(props); } render() { return (

Input Render:

{this.props.input}

); } }; ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```