-
Notifications
You must be signed in to change notification settings - Fork 148
fix(ModelessDialog): title propsがReactNodeを受け取れるように修正 #5907
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
Open
Qs-F
wants to merge
5
commits into
master
Choose a base branch
from
fix/modeless-dialog/title-can-be-reactnode
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18
−9
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
64da431
feat: add PropsWithHTMLAttributes type
Qs-F 8a505c9
fix(ModelessDialog): title propsがReactNodeを受け取れるように修正
Qs-F 121ab52
Merge branch 'master' into fix/modeless-dialog/title-can-be-reactnode
AtsushiM 8a4a6a1
refactor: PropsWithHTMLAttributesから不要なParameters<FC>[0]を削除
AtsushiM a45945c
refactor(ModelessDialog): 型定義を簡潔化
AtsushiM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| import type { ComponentPropsWithRef, ElementType } from 'react' | ||
| import type { ComponentPropsWithRef, ComponentPropsWithoutRef, ElementType, FC } from 'react' | ||
|
|
||
| export type ElementRef<T extends ElementType> = ComponentPropsWithRef<T>['ref'] | ||
|
|
||
| export type ElementRefProps<T extends ElementType> = { ref?: ElementRef<T> } | ||
|
|
||
| export type PropsWithHTMLAttributes< | ||
| Props extends Parameters<FC>[0], | ||
|
AtsushiM marked this conversation as resolved.
Outdated
|
||
| E extends ElementType, | ||
|
AtsushiM marked this conversation as resolved.
Outdated
|
||
| > = Props & Omit<ComponentPropsWithoutRef<E>, keyof Props> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React の ComponentProps と見間違うかも。
FC<>に直接書いちゃうかModelessDialogPropsとするかかと思いました。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reactのComponentProps型はrefを受け取れるかどうか明確ではないため事故の原因になりやすく、慣習的に基本的に使わないべきはずです!あとここはrefを受け取ることが明確ではないため、やるならModelessDialogPropsWithoutRefになりますが、ほかのコンポーネントでも同様の書き方のパターンが出てくるのでComponentPropsが1番良いのではと思っての判断でした
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
他コンポーネントは
Propsを FC に渡してることが一番多い気がします。ModelessDialog の Props の名前を変えて、ここを Props とする手もありそうです。
React の ComponentProps 型を使わないのはわかるけど、
FC<ComponentProps>だけ見るとうーんってなりました。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
多分認識のズレが起きてそうで
u: ComponentPropsという名前だとReact.ComponentPropsと勘違いするかもだから他の名前にしたほうが良くない?
ってことを言われている気がします。
慣習的に使わないとしても名前がダブるので他の名前にするかFCに直接渡すほう良い、という意見だと思います。
↑であっているとしたら俺も同意見です。