Skip to content
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

Document useEntityProp() hook #9

Open
helgatheviking opened this issue Mar 28, 2024 · 1 comment
Open

Document useEntityProp() hook #9

helgatheviking opened this issue Mar 28, 2024 · 1 comment

Comments

@helgatheviking
Copy link

I came across this yesterday when building out a custom block and I found it used in one or two blog tutorials (example) but couldn't find it in the documentation.

@flexseth
Copy link
Contributor

flexseth commented Apr 3, 2024

I came across this yesterday when building out a custom block and I found it used in one or two blog tutorials (example) but couldn't find it in the documentation.

I believe the documentation is not automatically populating, possibly because there isn't a JS DocBlock associated with the source code in Core. Not sure how this data is pulled into the Plugins Handbook...

Here's the code from the Block Editor source

https://github.com/WordPress/gutenberg/blob/80ff5e84793888f9891b66f737f7bb5d84818237/packages/editor/src/bindings/post-meta.js#L4

What does it do?

It looks like the useEntityProp hook is used contextually access post_meta from the @wordpress/core-data datastore. It's a fairly advanced JavaScript hook that can be a bit confusing to implement.

Where can I find an example use?

This may be a good candidate for the block-development-examples repo.

Or discussion can be had if adding comments in the documentation will auto-populate the info for the hook.

If you want to raise a question about an example for useEntityProp in the block-development-examples repo - that may be a good place for a simple example of what this hook does.

Or maybe it should be provided in the Plugins Handbook, unsure of the scope.

Here's a video that may go over the hook
https://www.youtube.com/watch?v=MtVRifFbUaQ

Here's a repo that may cover it already...
https://github.com/ryanwelcher/twitch/tree/65d1f9f5b7ea65b4388ea02a16c974752ad1872e/plugins/display-meta

Finished prototype from the video above
https://blockdevelopercookbook.com/recipes/post-meta-testimonial-block/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants