-
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
Add/block breadcrumb component readme #24827
Add/block breadcrumb component readme #24827
Conversation
<div className="add-your-class-name"> | ||
<BlockBreadcrumb /> | ||
</div> | ||
``` |
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 think most components in the block-editor
package including this one need to be embedded in the React tree under BlockEditorProvider
. I wonder if it's worth mentioning in the READMEs of the different components or not.
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.
Yes, I think we should include in each example, because a developer may approach any page without seeing others, the more we can do to make the examples "just work" when copy-and-paste the better.
The example could be just updated to, if you want to include the <div>
it'd be fine too, but probably not necessary.
import {
BlockBreadcrumb,
BlockEditorProvider } from '@wordpress/block-editor';
<BlockEditorProvider>
<BlockBreadcrumb/>
</BlockEditorProvider>
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.
That's not sufficient though because using BlockEditorProvider
is more complex than that. Maybe we can link to its README?
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.
Ok, just updated the example with BlockEditorProvider
.
Is there anything thing else that should be added?
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.
Maybe add something in a "Related components" section?
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 personally think we should revert to your original code example but add a sentence like that somewhere:
Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a `BlockEditorProvider` in the components tree.
and link the word BlockEditorProvider
to its README.
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.
✅
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.
Works for me. The BlockEditorProvider readme has a complete example 👍
|
||
<div className="add-your-class-name"> | ||
<BlockBreadcrumb /> | ||
</div> |
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 is bad code, it needs to be wrapper inside a function (component), we can't just use JSX top level like that.
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.
something like
const MyBreadcrumb = () => <BlockBreadcrumb />;
I guess.
I think I can also remove the div.
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.
LGTM 👍
Description
Added documentation for the block breadcrumb component (see #22891)
How has this been tested?
N/A, documentation only
Types of changes
Documentation
Checklist: