-
Notifications
You must be signed in to change notification settings - Fork 4.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
SlotFill: several code cleanups #50098
Conversation
Size Change: -89 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
} | ||
|
||
const Fill = ( props ) => ( |
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.
I wonder why we had this in the first place.
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.
FillComponent
used to be a class component, wrapped in a context consumer component, and then it was refactored to functional with hooks in #15541. But the PR kept the context consumer wrapper, it didn't migrate it to useContext
.
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.
Good cleanup
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.
Going to need a CHANGELOG entry, but other than that looks great 👍 🚀
That CI check is optional, and this PR doesn't make any user observable changes. The changelog entry can hardly say anything more than "code cleanup, removed unused code" and that's not meaningful to the library user. That's why I'll merge without a changelog entry. |
While learning about how
SlotFill
exactly works, I found some unused code or cleanup opportunities, and I'm submitting them here.Fill
component (the non-bubbling) version was composed from a functionalFillComponent
wrapped inside aSlotFillContext.Consumer
component. By using theuseContext( SlotFillContext )
hook, we can merge the entire functionality into one functional component.SlotFillProvider
component has ahasFills
method that's not used anywhere, and the context is also not exposed as public API. It can be removed.Slot
andFill
components have unused code -- thebindNode
method and acreatePortal
call -- that was used only in thebubblesVirtually
version which was extracted into separate components in Components: Refactor SlotFill #19242. It can be removed completely from the non-bubbling version.useSlot
can be written as oneexport from
call. Just like the adjacent export ofuseSlotFills
.How to test:
Check that all unit and e2e tests are passing after changing these widely used components.