--- id: 5a24c314108439a4d4036145 title: Map State to Props challengeType: 6 isRequired: false videoUrl: '' localeTitle: خريطة الدولة إلى الدعائم --- ## Description undefined ## Instructions
قم بإنشاء mapStateToProps() دالة. يجب أن تأخذ هذه الدالة state كوسيطة ، ثم تقوم بإرجاع كائن يقوم بتعيين هذه الحالة إلى أسماء خصائص محددة. ستصبح هذه الخصائص متاحة للمكون الخاص بك عبر props . نظرًا لأن هذا المثال يحافظ على الحالة الكاملة للتطبيق في صفيف واحد ، فيمكنك تمرير هذه الحالة بأكملها إلى المكون الخاص بك. قم بإنشاء messages خاصية في الكائن الذي يتم إرجاعه وتعيينه إلى state .
## Tests
```yml tests: - text: وCONST state يجب أن تكون مجموعة فارغة. testString: 'assert(Array.isArray(state) && state.length === 0, "The const state should be an empty array.");' - text: '' testString: 'assert(typeof mapStateToProps === "function", "mapStateToProps should be a function.");' - text: '' testString: 'assert(typeof mapStateToProps() === "object", "mapStateToProps should return an object.");' - text: '' testString: 'assert(mapStateToProps(["messages"]).messages.pop() === "messages", "Passing an array as state to mapStateToProps should return this array assigned to a key of messages.");' ```
## Challenge Seed
```jsx const state = []; // change code below this line ```
## Solution
```js // solution required ```