Hi! I'm having issues with a pageview triggering m...
# questions
h
Hi! I'm having issues with a pageview triggering many times after one another. This isn't always happening but it has been happening in some places, or at least we think so. Am using React, and this hook:
Copy code
export const usePageView = (pageName, extraProperties) => {
  const tracking = useTracking();
  const location = useLocation();
  const params = useParams();

  const mergeProperties = useCallback(() => {
    return { ...params, ...location, ...extraProperties };
  }, [extraProperties, location, params]);

  const [trackProperties, setTrackProperties] = useState(mergeProperties());

  useEffect(() => {
    const newProperties = mergeProperties();
    if (!equal(newProperties, trackProperties)) {
      setTrackProperties(newProperties);
    }
  }, [mergeProperties, trackProperties]);

  useEffect(() => {
    const eventName = tracking.EventNameCreators.pageView(pageName);
    tracking.trackEvent(eventName, trackProperties);
  }, [pageName, trackProperties, tracking]);
};
Implemented like so:
Copy code
const CompanyInfoPage = () => {
  usePageView('company_info')
...
Can someone spot what might be going on?