favicon
テストメーカー
テストを作成
  1. TOP
  2. /
  3. 公開テスト一覧
  4. /
  5. IT・プログラミング
  6. /
  7. Reactドキュメントで学ぶ英語 ~Reducer~

Reactドキュメントで学ぶ英語 ~Reducer~

作者: aaa

回答 23件

引用元: https://beta.reactjs.org/learn/extracting-state-logic-into-a-reducer 

Reactドキュメントから抜粋した英文と英訳文の穴埋めを埋めつつReact知識の補完をしましょう。



Components with many (1) updates spread across many event handlers can get overwhelming. For these cases, you can consolidate all the state update logic outside your component in a single function, called a reducer.

多くの状態更新が多くのイベントハンドラに(2)しているコンポーネントは、(3)されることがあります。このような場合、コンポーネントの(4)にあるすべての状態更新ロジックを、リデューサと呼ばれる単一の関数に(5)することができます。



As your components grow in complexity, it can get harder to see at a glance all the different ways in which a component’s state gets updated.

コンポーネントが(6)になると、コンポーネントの状態が更新される(7)な方法を(8)で確認することが難しくなります。



An action object can have any shape. By convention, it is common to give it a string type that describes what happened, and pass any additional information in other fields.

アクションオブジェクトは(9)の形状を持つことができます。(10)として、何が起こったかを(11)文字列型を与え、他のフィールドに追加情報を渡すのが(12)的です。



Comparing useState and useReducer

Reducers are not without downsides! Here’s a few ways you can compare them: Reducerには(13)がないわけではない! ここでは、その比較方法をご紹介します。

  • Readability: useState is very easy to read when the state updates are simple. When they get more complex, they can bloat your component’s code and make it difficult to scan. In this case, useReducer lets you cleanly separate the how of update logic from the what happened of event handlers. useStateは、状態の更新が単純な場合は非常に読みやすい。しかし、更新が複雑になると、コンポーネントのコードが(14)し、スキャンしづらくなります。このような場合、useReducerを使うと、更新ロジックのHowとイベントハンドラのWhat happenedをきれいに(15)することができます。
  • Testing: A reducer is a pure function that doesn’t depend on your component. This means that you can export and test it separately in isolation. While generally it’s best to test components in a more realistic environment, for complex state update logic it can be useful to assert that your reducer returns a particular state for a particular initial state and action. Reducerは、あなたのコンポーネントに(16)しない(17)な関数です。つまり、(18)して別々にエクスポートしてテストすることができます。一般的には、より(19)的な環境でコンポーネントをテストするのがベストですが、複雑な状態更新ロジックでは、(20)の初期状態とアクションに対してリデューサが(21)の状態を返すことを(22)するのが便利です。















出題内容

  • 問1: Components with many ____ updates spread across many event handlers can get overwhelming. For these cases, you can consolidate all the state update logic outside your component in a single function, called a reducer.
  • 問2: 多くの状態更新が多くのイベントハンドラに____しているコンポーネントは、____されることがあります。このような場合、コンポーネントの____にあるすべての状態更新ロジックを、リデューサと呼ばれる単一の関数に____することができます。
  • 問3: コンポーネントが____になると、コンポーネントの状態が更新される____な方法を____で確認することが難しくなります。
  • 問4: アクションオブジェクトは____の形状を持つことができます。____として、何が起こったかを____文字列型を与え、他のフィールドに追加情報を渡すのが____的です。
  • 問5: Reducers are not without downsides! Here’s a few ways you can compare them: Reducerには____がないわけではない! ここでは、その比較方法をご紹介します。

...他17問(続きはテストで確認!)