-
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 in the post-taxonomies components #58446
Conversation
Size Change: -5 B (0%) Total Size: 1.7 MB
ℹ️ View Unchanged
|
rerender( | ||
<PostTaxonomies | ||
postType="book" | ||
taxonomies={ [ | ||
genresTaxonomy, | ||
{ | ||
...categoriesTaxonomy, | ||
types: [ 'post', 'page', 'book' ], | ||
}, | ||
] } | ||
/> | ||
); | ||
|
||
expect( screen.getByRole( 'group', { name: 'Genres' } ) ).toBeVisible(); | ||
expect( | ||
screen.getByRole( 'group', { name: 'Categories' } ) | ||
).toBeVisible(); | ||
expect( | ||
screen.getByRole( 'button', { name: 'Add new genre' } ) | ||
).toBeVisible(); | ||
expect( | ||
screen.getByRole( 'button', { name: 'Add new category' } ) | ||
).toBeVisible(); |
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.
I have removed these assertions as they weren't testing real scenarios. The taxonomy definitions are coming from the server, and they don't change after the initial render.
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.
LGTM 👍 Thanks @Mamaduka! 🚀
taxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ), | ||
}; | ||
}, [] ); | ||
const visibleTaxonomies = ( taxonomies ?? [] ).filter( |
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.
Nice work combining the 2 filter()
calls in a single one 👍
Thanks for the review, @tyxla! |
What?
PR updates the
PostTaxonomiesCheck
andPostTaxonomies
components to use data hooks instead of HoCs.Why?
A micro-optimization makes the rendered component tree smaller.
This is similar to #53773.
Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast
Before
After