From 450b9788431cb99b0627ac945f7f5917b7507e74 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Marceau <39384459+jpmarceau@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:19:01 -0500 Subject: [PATCH] Fred's comment https://coveord.atlassian.net/browse/KIT-3826 --- .../headless-ssr-commerce/components/product-viewer.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/samples/headless-ssr-commerce/components/product-viewer.tsx b/packages/samples/headless-ssr-commerce/components/product-viewer.tsx index 0af29e4cf94..50f24b0a67f 100644 --- a/packages/samples/headless-ssr-commerce/components/product-viewer.tsx +++ b/packages/samples/headless-ssr-commerce/components/product-viewer.tsx @@ -1,7 +1,7 @@ 'use client'; import {useProductView} from '@/lib/commerce-engine'; -import {useEffect, useRef} from 'react'; +import {useEffect} from 'react'; interface Product { productId: string; @@ -11,12 +11,12 @@ interface Product { export default function ProductViewer({productId, name, price}: Product) { const {methods} = useProductView(); - const productViewEventEmitted = useRef(false); + let productViewEventEmitted = false; useEffect(() => { - if (methods && !productViewEventEmitted.current) { + if (methods && !productViewEventEmitted) { methods?.view({productId, name, price}); - productViewEventEmitted.current = true; + productViewEventEmitted = true; } }, []);