-
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
RichText: rewrite withFilters with hooks #19117
Conversation
397184d
to
f6bda37
Compare
export { useDispatch } from './components/use-dispatch'; | ||
export { | ||
useDispatch, | ||
useDispatchWithMap as __unstableUseDispatchWithMap, |
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.
@youknowriad Just wanted to make you aware that I'm exporting useDispatchWithMap
here (unstable API). It's needed for RichText
because the format type needs access to dispatch
to pick a store. I don't think there's any way around it, but maybe you have a better insight.
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.
the format type needs access to dispatch to pick a store
Maybe, there's an alternative way to provide access to the hook in these types. Could you give a quick example about how we use dispatch in the formats?
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.
Sure:
gutenberg/packages/annotations/src/format/annotation.js
Lines 147 to 152 in 30483ce
__experimentalGetPropsForEditableTreeChangeHandler( dispatch ) { | |
return { | |
removeAnnotation: dispatch( STORE_KEY ).__experimentalRemoveAnnotation, | |
updateAnnotationRange: dispatch( STORE_KEY ).__experimentalUpdateAnnotationRange, | |
}; | |
}, |
ff46818
to
13a20f7
Compare
Did a performance check and the results vary with slightly better performance for this branch. |
8b37ea5
to
4c84630
Compare
Headsup, |
Description
Removes
rich-text
's dependency on thehooks
package.Currently some props are added for the annotation format types with WordPress hooks. This is unnecessary, because
RichText
has access to the format types. Additionally the addition of the props can be simplified with hooks and a single wrapper component.How has this been tested?
Screenshots
Types of changes
Checklist: