Skip to content

Commit

Permalink
move the filter inside the useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Jul 2, 2024
1 parent 01136f1 commit a68c2ce
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function useCurrentMergeThemeStyleVariationsWithUserConfig( property ) {
}, [] );
const { user: userVariation } = useContext( GlobalStylesContext );

const variationsByProperty = useMemo( () => {
return useMemo( () => {
const clonedUserVariation = cloneDeep( userVariation );

// Get user variation and remove the settings for the given property.
Expand All @@ -105,20 +105,20 @@ export function useCurrentMergeThemeStyleVariationsWithUserConfig( property ) {
);
} );

return [
const variationsByProperty = [
userVariationWithoutProperty,
...variationsWithSinglePropertyAndBase,
];
}, [ property, userVariation, variationsFromTheme ] );

/*
* Filter out variations with no settings or styles.
*/
return variationsByProperty?.length
? variationsByProperty.filter(
( variation ) => ! isEmptyStyleVariation( variation )
)
: [];
/*
* Filter out variations with no settings or styles.
*/
return variationsByProperty?.length
? variationsByProperty.filter(
( variation ) => ! isEmptyStyleVariation( variation )
)
: [];
}, [ property, userVariation, variationsFromTheme ] );
}

/**
Expand Down

0 comments on commit a68c2ce

Please sign in to comment.