-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Popover] Convert Popover to functional component #2386
Conversation
f976091
to
8d74611
Compare
Just changing this to WIP because it will conflict with @AndrewMusgrave PR [#2255] so might as well wait to review. |
src/components/Popover/Popover.tsx
Outdated
@@ -26,7 +34,7 @@ export interface PopoverProps { | |||
* The element type to wrap the activator with | |||
* @default 'div' | |||
*/ | |||
activatorWrapper?: string; | |||
activatorWrapper?: HTMLOnlyJsxIntrinsicElementsKeys; |
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.
Running a type-check locally I don't have any problems keeping this a string?
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.
It's fine to keep as a string from a typing perspective, but this is a little stricter. Before settling on the React.createElement
approach I was trying to ensure you could only pass valid tagnames into this as while <div />
is fine, <divvvvvv />
is a type error and that caused problems with how we were trying to get types of <WrapperComponent>
. This typing helped limit the activatorWrapper to only strings that were valid JSX. But in the end we didn't need that as createElement
's first arg is typed as a string anyway.
Ben added that to tighten the interface. Not sure if it's worth the impact. The real issue was
TypeScript wasn't liking this. The workaround was to use createElement instead:
|
I agree that tightening up the type is a good idea, but I would technically call this a breaking change. Would you agree? |
8d74611
to
10b1f4f
Compare
I've removed the tightened type. Maybe its something we can add in a major version but for now, it's probably not worth the change. This is ready for review. |
10b1f4f
to
315f064
Compare
895e0f3
to
8e92c72
Compare
8e92c72
to
ca05ddb
Compare
ca05ddb
to
9ae691e
Compare
related to: #1995
WHY are these changes introduced?
I'm wanting to make use of a hook inside popover for my current project, so I took the opportunity to convert popover to a function components.
WHAT is this pull request doing?
Functionality remains the same. However there are changes.
2. Use React.createElement to workaround creating jsx typing issue with the WrapperComponent3. Tighten the type of activatorWrapper too so that it may only include strings of element names, e.g. 'button' and 'div' are valid, but not 'fff' or 'Button'(breaking change)thank you for those last two @BPScott!
How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist
README.md
with documentation changes