Pass proper data to On Sale badge when used in the scope of Product Image (https://github.com/woocommerce/woocommerce-blocks/pull/9021)

* Don't use withProductDataContext in Sale Badge block

There was no information about product passed to the block, so it fetched information about all products which then wasn't even used

* Pass necessary props to the Sale Badge so it doesn't overfetch unnecessary data

* Move the import to the previous place
This commit is contained in:
Karol Manijak 2023-04-18 14:53:50 +02:00 committed by GitHub
parent cbec25c463
commit f3c28b9d78
1 changed files with 2 additions and 1 deletions

View File

@ -85,6 +85,7 @@ export const Block = ( props: Props ): JSX.Element | null => {
showProductLink = true,
showSaleBadge,
saleBadgeAlign = 'right',
...restProps
} = props;
const { parentClassName } = useInnerBlockLayoutContext();
const { product, isLoading } = useProductDataContext();
@ -153,7 +154,7 @@ export const Block = ( props: Props ): JSX.Element | null => {
{ !! showSaleBadge && (
<ProductSaleBadge
align={ saleBadgeAlign }
product={ product }
{ ...restProps }
/>
) }
<Image