Skip to content

Commit 9a7cd86

Browse files
committed
Check if we are in browser before using DOMParser
1 parent 125fac6 commit 9a7cd86

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

refactor/src/components/Product/SingleProduct.component.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import LoadingSpinner from '@/components/LoadingSpinner/LoadingSpinner.component
1717
const SingleProduct = ({ product }: any) => {
1818
const [isLoading, setIsLoading] = useState<boolean>(true);
1919
const [selectedVariation, setSelectedVariation] = useState<string>();
20+
let DESCRIPTION_WITHOUT_HTML
2021

2122
useEffect(() => {
2223
setIsLoading(false);
@@ -41,10 +42,12 @@ const SingleProduct = ({ product }: any) => {
4142
}
4243

4344
// Strip out HTML from description
44-
const DESCRIPTION_WITHOUT_HTML = new DOMParser().parseFromString(
45+
if(process.browser){
46+
DESCRIPTION_WITHOUT_HTML = new DOMParser().parseFromString(
4547
description,
4648
'text/html'
4749
).body.textContent;
50+
}
4851

4952
const placeholderFallBack = 'https://via.placeholder.com/600';
5053

0 commit comments

Comments
 (0)