-
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
Editor: Use hooks instead of HoCs in PostPendingStatusCheck
#53389
Conversation
if ( isPublished || ! hasPublishAction ) { | ||
return null; | ||
} | ||
|
||
return children; | ||
} | ||
|
||
export default compose( |
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.
compose
usage was unnecessary here because we were using only one HoC.
hasPublishAction: | ||
getCurrentPost()._links?.[ 'wp:action-publish' ] ?? false, | ||
isPublished: isCurrentPostPublished(), | ||
postType: getCurrentPostType(), |
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.
In addition to moving from withSelect
, we're no longer returning the postType
prop since it was not in use.
Size Change: -11 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.
A nice refactoring!
What?
This straightforward PR updates the
PostPendingStatusCheck
component to use the@wordpress/data
hooks instead of the HoCs.Related to #53387.
Why?
A micro-optimization to makes the rendered component tree smaller.
How?
We're using the
useSelect
hook instead of thewithSelect
HoC.Because we're removing a
withSelect
and acompose()
instance, this removes 2 levels of nesting.Testing Instructions
Creating a new post and editing an existing post, verifying the "Pending review" field in the post sidebar still works well. It should still not appear if a post is already published.
Testing Instructions for Keyboard
None.
Screenshots or screencast
The component tree before:
The component tree after: