Skip to content

Commit e1b58c4

Browse files
committed
Update SingleProduct.component.tsx
1 parent de2c99a commit e1b58c4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/components/Product/SingleProduct.component.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const SingleProduct: React.FC<IProductRootObject> = ({ product }) => {
1111

1212
const placeholderFallBack = 'https://via.placeholder.com/600';
1313

14-
let DESCRIPTION_WITHOUT_HTML: string | undefined;
14+
let DESCRIPTION_WITHOUT_HTML: string | null = null;
1515

1616
useEffect(() => {
1717
setIsLoading(false);
@@ -28,11 +28,10 @@ const SingleProduct: React.FC<IProductRootObject> = ({ product }) => {
2828
if (regularPrice) regularPrice = paddedPrice(regularPrice, 'kr');
2929
if (salePrice) salePrice = paddedPrice(salePrice, 'kr');
3030

31-
if (typeof window !== 'undefined') {
32-
DESCRIPTION_WITHOUT_HTML = new DOMParser().parseFromString(
33-
description,
34-
'text/html',
35-
).body.textContent;
31+
if (typeof window !== 'undefined' && description) {
32+
DESCRIPTION_WITHOUT_HTML =
33+
new DOMParser().parseFromString(description, 'text/html').body
34+
.textContent || '';
3635
}
3736

3837
return (

0 commit comments

Comments
 (0)