Aren't updater functions in state an antipattern?
オープン
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
In documentation here:
https://reactjs.org/docs/context.html#updating-context-from-a-nested-component
An updater function is placed directly in the state object for the sole purpose of passing it down through context:
this.state = {
theme: themes.light,
toggleTheme: this.toggleTheme,
};
This seems like an odd antipattern. I've never placed a method in state before. Shouldn't state be exclusively for properties that affect rendering and change over time?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンク先の React Context ドキュメント、特に「Updating Context from a Nested Component」セクションと、その updater-in-state の例を確認してください。この例に明確化または修正が必要かどうかを判断し、ドキュメントでこのパターンについて明確で合意された説明が提供された時点で作業完了としてください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100