--- id: 5a24c314108439a4d403614e title: Define an Action Creator challengeType: 6 isRequired: false forumTopicId: 301441 localeTitle: 定义一个 Action Creator --- ## Description
创建 action 后要将 action 发送到 Redux store,以便它可以更新其状态。在 Redux 中,你可以定义动作创建器来完成此任务,action creator 只是一个返回动作的 JavaScript 函数,换句话说,action creator 创建表示动作事件的对象。
## Instructions
定义名为actionCreator()的函数,该函数在调用时返回action对象。
## Tests
```yml tests: - text: 函数actionCreator应该存在。 testString: assert(typeof actionCreator === 'function'); - text: 运行actionCreator函数应返回 action 对象。 testString: assert(typeof action === 'object'); - text: 返回的 action 应具有值为LOGIN的键值类型。 testString: assert(action.type === 'LOGIN'); ```
## Challenge Seed
```jsx const action = { type: 'LOGIN' } // 在此处定义 action creator ```
## Solution
```js const action = { type: 'LOGIN' } // 在此处定义 action creator: const actionCreator = () => { return action; }; ```