React docs on "Building Your Own Hooks"
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 11.8k
- フォーク
- 7.9k
- 平均マージ
- 1日 11時間
- マージ済み PR(30日)
- 11
説明
Please provide guidance if returning elements (or ()=>elements) from custom hook is a good practice or not.
We have a PageLayout component like the following in our own app:
<PageLayout
topBarButtons={..}
onRender={..}
/>
We want to encapsulate topBarButtons and onRender logic within a custom hook, so that the hook is reusable and shippable without PageLayout. (topBarButtons and onRender will share some state, and useOurHook returns [topBarButtons, onRenderFunc]).
This works fine, if not perfect, for me. But since there are so few custom hook example that returns UI elements (or function that returns UI elements like onRender), the team have doubt about this pattern.
I know the doc has the following statement, but I think this is a very common scenario that deserves a sentence or two in the React docs.
"useYourImagination()
Custom Hooks offer the flexibility of sharing logic that wasn’t possible in React components before. You can write custom Hooks that cover a wide range of use cases like form handling, animation, declarative subscriptions, timers, and probably many more we haven’t considered."
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
"Building Your Own Hooks" のドキュメントページから始め、custom Hooks に関する既存のガイダンスと例を確認してください。要素、または要素を返す関数を返すことが適切なパターンかどうかについて、このページで説明されている共有状態のシナリオも含め、簡潔な説明を追加してください。このページだけでチームの質問に答えられるようにし、この issue のアプリケーション固有のコンテキストを必要としないものにしてください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, react
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 50/100