Files
2022-01-20 20:30:18 +01:00

1.4 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
5a24c314108439a4d403614e アクションクリエイターを定義する 6 301441 define-an-action-creator

--description--

アクションを作成したら、次のステップとして Redux ストアにアクションを送信し、状態を更新できるようにします。 Redux では、アクションクリエイターを定義してこの処理を実行します。 アクションクリエイターとは、単にアクションを返す JavaScript 関数です。 別の言い方をすれば、アクションクリエイターはアクションイベントを表すオブジェクトを作成します。

--instructions--

呼び出されたときに action オブジェクトを返す actionCreator() という関数を定義してください。

--hints--

関数 actionCreator が存在する必要があります。

assert(typeof actionCreator === 'function');

actionCreator 関数の実行で、action オブジェクトを返します。

assert(typeof action === 'object');

返される action に、値 LOGIN を持つキープロパティ type を持たせます。

assert(action.type === 'LOGIN');

--seed--

--seed-contents--

const action = {
  type: 'LOGIN'
}
// Define an action creator here:

--solutions--

const action = {
  type: 'LOGIN'
}
const actionCreator = () => {
  return action;
};