Skip to content

Commit

Permalink
Lodash: Refactor blocks away from _.map() (#47188)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Jan 17, 2023
1 parent 7824a63 commit 2f8c572
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/blocks/src/store/reducer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import { get, isEmpty, map, mapValues } from 'lodash';
import { get, isEmpty, mapValues } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -269,7 +269,7 @@ export function categories( state = DEFAULT_CATEGORIES, action ) {
( { slug } ) => slug === action.slug
);
if ( categoryToChange ) {
return map( state, ( category ) => {
return state.map( ( category ) => {
if ( category.slug === action.slug ) {
return {
...category,
Expand Down
11 changes: 5 additions & 6 deletions packages/blocks/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import createSelector from 'rememo';
import removeAccents from 'remove-accents';
import { get, map } from 'lodash';
import { get } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -553,12 +553,11 @@ export function getGroupingBlockName( state ) {
*/
export const getChildBlockNames = createSelector(
( state, blockName ) => {
return map(
getBlockTypes( state ).filter( ( blockType ) => {
return getBlockTypes( state )
.filter( ( blockType ) => {
return blockType.parent?.includes( blockName );
} ),
( { name } ) => name
);
} )
.map( ( { name } ) => name );
},
( state ) => [ state.blockTypes ]
);
Expand Down

0 comments on commit 2f8c572

Please sign in to comment.