Skip to content
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

Tag Cloud: Replace 'withSelect' HoC with 'useSelect' #57194

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/block-library/src/tag-cloud/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
Disabled,
} from '@wordpress/components';
import { withSelect } from '@wordpress/data';
import { useSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import {
InspectorControls,
Expand All @@ -40,7 +40,7 @@ const MAX_TAGS = 100;
const MIN_FONT_SIZE = 0.1;
const MAX_FONT_SIZE = 100;

function TagCloudEdit( { attributes, setAttributes, taxonomies } ) {
function TagCloudEdit( { attributes, setAttributes } ) {
const {
taxonomy,
showTagCounts,
Expand All @@ -53,6 +53,10 @@ function TagCloudEdit( { attributes, setAttributes, taxonomies } ) {
const units = useCustomUnits( {
availableUnits: availableUnits || [ '%', 'px', 'em', 'rem' ],
} );
const taxonomies = useSelect(
( select ) => select( coreStore ).getTaxonomies( { per_page: -1 } ),
[]
);

const getTaxonomyOptions = () => {
const selectOption = {
Expand Down Expand Up @@ -174,8 +178,4 @@ function TagCloudEdit( { attributes, setAttributes, taxonomies } ) {
);
}

export default withSelect( ( select ) => {
return {
taxonomies: select( coreStore ).getTaxonomies( { per_page: -1 } ),
};
} )( TagCloudEdit );
export default TagCloudEdit;