Possible conceptual pitfall when discussing accessing a state variable set in a previous render
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
Hi there!
In this section: https://react.dev/learn/you-might-not-need-an-effect#adjusting-some-state-when-a-prop-changes
It took me a while to understood that prevItems would not be changed until setItems was invoked on it. What tripped me there was that I thought that useState(X) always set items to X on every re-render. Once I understood that prevItems is set to X only when the state is initialized, everything is clear.
This might perhaps be a good place in the docs to clarify (either on a couple of sentences or on its own Pitfall section) that setState will only initialize a value, but not update it during a re-render.
I take this opportunity for congratulating the team on the new React docs. There are one of the best technical documentation pieces I've read in my entire career. 🚀
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
React ドキュメントのリンク先にある「Adjusting some state when a prop changes」セクションを読み、レンダー間での useState と setState の説明を確認してください。セクションが状態の初期化と後続の更新を明確に区別し、報告された誤解を扱っていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100