Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
fix(hooks): prevent duplicated page view events (#89)
Browse files Browse the repository at this point in the history
Wrap the page view trigger in `useCallback`.
  • Loading branch information
connor-baer authored Mar 22, 2021
1 parent 3e7150d commit 7ceeedd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/hooks/usePageViewTrigger/usePageViewTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@
* limitations under the License.
*/

import * as React from 'react';

import useBaseTrigger from '../useBaseTrigger';
import { Events } from '../../types';

const usePageViewTrigger = () => {
const dispatch = useBaseTrigger(Events.pageView);

return () => dispatch({});
const handleTrigger = React.useCallback(() => dispatch({}), [dispatch]);

return handleTrigger;
};

export default usePageViewTrigger;

0 comments on commit 7ceeedd

Please sign in to comment.