Explain why componentDidMount is a better place to make an ajax request
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
In the docs, in componentWillMount section section it says:
Avoid introducing any side-effects or subscriptions in this method
And in the componentDidMount section:
If you need to load data from a remote endpoint, this is a good place to instantiate the network request
Which for me is confusing because I won't like to wait for the component to be mounted to dispatch an ajax call to fulfill the component data dependencies. I would like to do it as soon as possible, like in the constructor, not even in componentWillMount.
Clearly you may have a reason why you say this in the docs, I might be not seeing the bigger picture. So it will be nice if you can explain a bit more in detail or point me in the direction of where I can find the reason.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
React ドキュメントの componentWillMount と componentDidMount に関するリンク先のセクションを、周辺のライフサイクルに関するガイダンスと併せて読んでください。ドキュメントがリモートリクエストを componentDidMount で開始することを推奨している理由を明確にし、マウントまで待つことへの懸念を扱ってください。タイミングに関するガイダンスとその根拠が明確になれば、issue は完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100