Open spencerfinnell opened 3 years ago
you can find a solution here....
https://wordpress.stackexchange.com/questions/352500/get-post-from-custom-rest-endpoint-in-gutenberg
The solution @yoscbd provided above does work, and I have implemented my own custom entities as well. Therefore, I am going to close this out.
Thank you for the link, however the solution linked does not address my original report (and I mention the ability to register entities with addEntities
).
Yes, you can register custom entities for use by some hooks/functions, but not all.
My original issue is support for useEntityProp
/EntityProvider
which does not work with the technique provided above because entity context is only created for locally imported entities, not all registered entities: https://github.com/WordPress/gutenberg/blob/2e40379781f0a188d46afcf4afefd0c1aaad1c5f/packages/core-data/src/entity-provider.js#L28
@ndiego is it possible to reopen this so it remains visible? The original report is still a reproducible issue and blocker for things like https://github.com/WordPress/gutenberg/issues/43751#issuecomment-1233815717
Yes, absolutely!
Is your feature request related to a problem? Please describe.
core-data
only creates context for default entities: https://github.com/WordPress/gutenberg/blob/master/packages/core-data/src/entity-provider.js#L20-L26However, custom entities can be added with the
addEntities
action. These entities then not seen as valid byuseEntityProp()
.Describe the solution you'd like Instead of pulling from a static list of entities, all registered entities should be given context.
Describe alternatives you've considered Currently I have duplicated
entity-provider.js
and reference the local provider vs. Gutenberg's when using a custom entity.