Render Props and PureComponent docs question/improvement opportunity
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
In the above link, the last section ("Caveats") talks about how one can avoid killing PureComponents benefits by pulling the render prop function out into an instance method. I understand why this is the case; the 'anonymous' function 'pointer' would change every render, so it isn't seen as something that didn't change, and the PureComponent would re-render all the time.
However, it says you can't do that with a PureComponent if the instance method / render prop needs to reference the component's state/props:
In cases where you cannot define the prop statically (e.g. because you need to close over the component's props and/or state)
<Mouse>should extendReact.Componentinstead.
I don't really understand why that is a limitation, so I'm proposing this as both a question and a suggestion for an update to the docs. I've never used or really looked into PureComponent, but from a look at the docs for them it seems like they re-render if a shallow comparison of it's props/state shows a difference. If that's the case, why wouldn't an instance function on Mouse that used it's own props/state work with PureComponent? The Mouse would re-render if one changed.
(Is it because the Cat - the child component of the render prop Mouse - wouldn't re-render, even though it's parent would?)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
content/docs/render-props.md を読み、特に最後の「Caveats」セクションと PureComponent に関するガイダンスを確認してください。props または state を使用するインスタンスの render-prop メソッドが PureComponent と互換性がないと説明されている理由を明確にし、子のレンダリング動作が関係するかどうかも説明してください。ドキュメントがこの疑問に直接答え、関連する制限を説明していれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100