Skip to content

Commit

Permalink
Merge pull request #801 from reactjs/smikitky/fix/800
Browse files Browse the repository at this point in the history
Fix typo in solution to third challenge problem in 'コンポーネントを純粋に保つ'
  • Loading branch information
smikitky authored Oct 10, 2024
2 parents afc9a16 + ed0188a commit 98c318c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/content/learn/keeping-components-pure.md
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ li {

<Solution>

時計が更新されるたびに、"Create Story" が *2 回*追加されることに気づくと、レンダー中にミューテーションが発生していることがわかるでしょ。Strict Mode は、このような問題をより目立たせるために、コンポーネントを 2 回呼び出します。
時計が更新されるたびに、"Create Story" が *2 回*追加されることに気づくと、レンダー中にミューテーションが発生していることがわかるでしょう。Strict Mode は、このような問題をより目立たせるために、コンポーネントを 2 回呼び出します。

問題は `StoryTray` 関数が純粋でないことです。受け取った `stories` 配列(props の一部です)に `push` を呼び出すことで、`StoryTray` がレンダーし始める*前に*作成されたオブジェクトをミューテートしてしまっています。これにより、バグや予測困難な動作につながります。

Expand Down

0 comments on commit 98c318c

Please sign in to comment.