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:
parent
cbec25c463
commit
f3c28b9d78
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue