Does `dispatch` function identity change when passed in context? [Re: eslint-plugin-react-hooks]
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
Issue:
-
The docs for useReducer suggests omitting
dispatchfrom the dependencies list ofuseEffectanduseReducer.Note
React guarantees thatdispatchfunction identity is stable and won't change on re-renders. This is why it's safe to omit from theuseEffectoruseCallbackdependency list. -
The docs also recommend passing
dispatchfunction fromuseReducervia context to avoid passing callbacks down a large component tree: -
eslint-plugin-react-hooks warns if
dispatch(that's been passed from context) is not added touseEffectdependencies list.This conflicts with the first point above (docs suggesting omitting
dispatchfrom the dependencies list)React Hook useCallback has a missing dependency: 'dispatch'. Either include it or remove the dependency array.
Is this:
- Expected behavior after passing
dispatchthrough context - so the docs should have a small amendment for this scenario? - Or a bug in
eslint-plugin-react-hooks?
Thanks for the help!!
Working Sample:
- Example Sandbox: https://codesandbox.io/s/vnq10rmwjy
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、リンク先の useReducer と Hooks FAQ のドキュメントを読み、その後 CodeSandbox で警告を再現し、eslint-plugin-react-hooks の動作と比較してください。ドキュメントに明確化が必要なのか、またはプラグインの動作に別途修正が必要なのかを判断し、関連する結論を記録できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- eslint, javascript, react
- 領域
- documentation, tooling
- issue の種類
- ドキュメント
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100