-
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
Editor: Use hooks instead of HoCs for PostPingbacks
#53228
Conversation
Size Change: +7 B (0%) Total Size: 1.44 MB
ℹ️ View Unchanged
|
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.
It works as expected. I couldn't stop any regressions.
const pingStatus = | ||
useSelect( | ||
( select ) => | ||
select( editorStore ).getEditedPostAttribute( 'ping_status' ), | ||
[] | ||
) ?? 'open'; |
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.
Nit (non-blocking): What do you think about returning the default value from inside the mapSelect
? For some reason, I found this pattern of useSelect() ?? defaultValue
bit odd 😅
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.
Sounds good 👍 Moved in 08ae4a0
Flaky tests detected in 08ae4a0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5726890781
|
What?
This straightforward PR updates the
PostPingbacks
component to use the@wordpress/data
hooks instead of the HoCs.Why?
A micro-optimization to makes the rendered component tree smaller.
How?
We're using the
useSelect
anduseDispatch
hooks instead of thewithSelect
andwithDispatch
hooks.Because we're removing a
withSelect
, awithDispatch
and acompose()
instance, this removes 3 levels of nesting.Testing Instructions
Creating a new post and editing a new post, verifying the "Allow pingbacks & trackbacks" field under "Discussion" settings in the post sidebar still works well.
Testing Instructions for Keyboard
None.
Screenshots or screencast
The component tree before:
The component tree after: