Gutenberg: Slot/Fill - `updateSlot` is missing from Slot Fill Context.

Created on 9 Jun 2020  路  3Comments  路  Source: WordPress/gutenberg

Describe the bug
I'm trying to use @wordpress/block-editor as a standalone library and copied the example.

I am unable to get it running because, it appears like this call:

https://github.com/WordPress/gutenberg/blob/8ac282605512cb4ee0c90973b60e1d01596df018/packages/components/src/slot-fill/bubbles-virtually/slot.js#L34

is failing because updateSlot is undefined as it's not part of the slot-fill-context.

https://github.com/WordPress/gutenberg/blob/8ac282605512cb4ee0c90973b60e1d01596df018/packages/components/src/slot-fill/bubbles-virtually/slot-fill-context.js#L6

Instead, it appears to have moved to the useSlot hook:
https://github.com/WordPress/gutenberg/blob/8ac282605512cb4ee0c90973b60e1d01596df018/packages/components/src/slot-fill/bubbles-virtually/use-slot.js#L18

In this PR:
https://github.com/WordPress/gutenberg/pull/19242

To reproduce
Steps to reproduce the behavior:
I used Create React App to get started.

  1. Create React app.
  2. Install everything listed in the @wordpress/block-editor example https://www.npmjs.com/package/@wordpress/block-editor#usage
  3. Try to run app.
  4. Expect to see this:
    Error Notice

Editor version (please complete the following information):
Pulled from package.json:

 {
    "@wordpress/block-editor": "^4.0.0",
    "@wordpress/block-library": "^2.19.0",
    "@wordpress/components": "^9.7.0",
    "@wordpress/element": "^2.14.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
}

Desktop (please complete the following information):

  • OS: macOs (Catalina)
  • Browser: Chrome
[Package] Block editor [Type] Bug

Most helpful comment

But I also wonder when using Slot/Fill without SlotFillProvider would make sense.

I think it鈥檚 must have to wrap both of them with SlotFillProvider. We could add some warnings to both of them to ensure it鈥檚 always properly configured.

All 3 comments

@youknowriad or @diegohaz, could you advise what would be the preferred fix here?

Due to the convention that this module adopts, I think the preferred fix is to simply add updateSlot as a noop function to the default object that is returned by the context (when SlotFillProvider isn't present). I'll fix this asap. But I also wonder when using Slot/Fill without SlotFillProvider would make sense.

But I also wonder when using Slot/Fill without SlotFillProvider would make sense.

I think it鈥檚 must have to wrap both of them with SlotFillProvider. We could add some warnings to both of them to ensure it鈥檚 always properly configured.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hedgefield picture hedgefield  路  3Comments

JohnPixle picture JohnPixle  路  3Comments

youknowriad picture youknowriad  路  3Comments

ellatrix picture ellatrix  路  3Comments

moorscode picture moorscode  路  3Comments