Skip to content

Commit

Permalink
Fred's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmarceau committed Jan 15, 2025
1 parent 74ee415 commit 450b978
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
}, []);

Expand Down

0 comments on commit 450b978

Please sign in to comment.