-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Show a warning when SlotFillProvider is missing #23493
Conversation
Size Change: +979 B (0%) Total Size: 1.13 MB
ℹ️ View Unchanged
|
@@ -4,6 +4,7 @@ | |||
import { createContext } from '@wordpress/element'; | |||
|
|||
const SlotFillContext = createContext( { | |||
__unstableDefaultContext: true, | |||
slots: {}, | |||
fills: {}, | |||
registerSlot: () => {}, |
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.
Could we warn instead when the default function that registers slots is called? This way we would avoid introducing the unstable property and the warning would fire in almost the same place.
I’m suggesting moving the warning call to registerSlot. What do you think?
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.
This makes a lot more sense. Will make the change.
Thanks for opening this PR. I had one minor consideration but we overall this PR looks good 👍 |
This PR closes #23388
Here I'm only adding a warning on the
Slot
component, and not on theuseSlot
hook.SlotFillProvider
andSlot
are optional for some components that calluseSlot
. For example,Popover
will render its contents within aFill
component only ifSlot
andSlotFillProvider
are present:gutenberg/packages/components/src/popover/index.js
Lines 590 to 592 in f9543e7
I also updated the
@wordpress/block-editor
package README, as it was causing confusion when people just copied and pasted the example code.How to test?