-
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
Blocks: Introduce 'getBlockIcon' and 'getBlockTitle` selectors #58641
Comments
We already have a |
The It's hard to use
Mainly for two reasons:
Sorry, I have trouble writing lengthy arguments due to a dislocated shoulder, but I hope I summarize it OK :) |
Why a selector instead of a hook? If we're duplicating the logic of |
The hooks create extra store subscriptions, and as I mentioned, it can affect performance. A big part of recent perf improvements was to reduce the number of store subs. See #57935. Also, why not the selectors? While I am happy to argue about the pros, nobody provided cons for introducing them. |
Selectors are usually fairly low level, tightly coupled to the store, and focused on retrieving or aggregating the state that's in that store. It's strange to me when a selector calls into another store, which these ones would need to do, though admittedly we already have plenty of this happening in Gutenberg via And it's strange to me that "presentation logic" such as this wouldn't be done in something quite high level i.e. a component or hook. But I suppose if it's quite common that we are duplicating this logic in various
Would it work if we used the pattern common in
I think the selectors would have to exist in |
We don't need data from the different stores if we pass the There's already a
Not anymore (See #58646). The blocks should use |
I think it's hard to say whether it should be a selector/hook/component. You mention that we need this in a few places and I think that's concrete evidence that we need something at least. Let's try to get something in and use it in all these places and see how it feels in the PR? Also we could see clearly the impact on performance. |
I'm going to close this proposal. The current hooks are good enough, and there's no apparent gain in terms of performance. If the block title or information hook becomes a bottle next in the app, I'll revisit this. |
A proposal to introduce
getBlockIcon
andgetBlockTitle
selectors for the Blocks store.Why
These values are crucial to the Block's identity and accessibility. They are fetched and rendered repeatedly throughout the editors. So, they should be easily accessible via selectors instead of relying on custom hooks.
cc @WordPress/gutenberg-core
The text was updated successfully, but these errors were encountered: