Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

細かな修正: providerとrouteをまとめる, jsDocの追加 #86

Merged
merged 10 commits into from
Nov 26, 2021

Conversation

h-jun01
Copy link
Contributor

@h-jun01 h-jun01 commented Nov 25, 2021

実装の概要

  • プロバイダーをひとまとめにした
  • ルーティングをいい感じにした
  • jsDocを追加

Trello #84
Closes #84

目的

レビューして欲しいところ

不安に思っていること

拡張入れたけど意外とjsDoc推論してくれなくて雰囲気で書いてる

スケジュール

  • マージすべき日、リリースすべき日の指定があれば書く

関連

  • 関係するプルリクエストなどがあれば書く

今後のタスク

  • レビュアーに伝えたいタスクがあればここに記入して伝える

Comment on lines 3 to 19
/**
* コンポーネントの遅延読み込み
*
* @param {() => Promise<I>} factory
* @param {K} name
*/
export const lazyImport = <
T extends React.ComponentType<FC>,
I extends { [K2 in K]: T },
K extends keyof I,
>(
factory: () => Promise<I>,
name: K,
): I => {
return Object.create({
[name]: React.lazy(() => factory().then(module => ({ default: module[name] }))),
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この遅延読み込みって具体的にどんなことしてるかわかる?
どういう時に使ったらいいのかわからないから、折角JSDoc書いてるんだしその説明も欲しいな

こういう使い方とかぱっと見わからないやつはJSDocの@example構文使うといいよ!
↓みたいな書き方する

/**
 * hogehgoe
 * @return {*}  {UseHoge}
 * @example
  ```js
    const hoge = useHoge() // テスト文章
  ```
 */

あと普通に中のコード何してるのかいまいちわからなくて気になるから、参考リンクあるなら欲しいw

Copy link
Contributor Author

@h-jun01 h-jun01 Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React.lazyの遅延読み込みはdefault exportにしか対応してなくて、それが嫌だなってことでnamed exportに対応させてるだけ!
facebook/react#14603

IMG_0594

IMG_0595

JSDoc追加する!ありがとう

Copy link
Contributor

@big-Miyabi big-Miyabi Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あ〜〜〜〜なるほど!
Suspence内で使うのね!前教えてくれた本の最新版か、買うわ

ありがとう!

@h-jun01 h-jun01 merged commit ed1ed31 into main Nov 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

細かな修正: providerとrouteをまとめる, jsDocの追加
2 participants