-
-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
Had an issue with this code
import ReactGA from 'react-ga4';
export const initGA = () => {
ReactGA.initialize('***');
};
export const logPageView = (page: string) => {
ReactGA.send({ hitType: 'pageview', page });
};
export const logEvent = (category: string, action: string, label?: string) => {
ReactGA.event({ category, action, label });
};
Where calling initGA, logPageView, logEvent from any components will cause Error: initialize, send, event are not functions.
Im using
React: 18.3.1
React DOM: 18.3.1
react-ga4: 2.1.0
TypeScript: 5.6.3
Webpack/Esbuild: Esbuild
My solution was to use default. E.g. ReactGA.default.initialize('***');
Is there any solution without using default?
Jleagle
Metadata
Metadata
Assignees
Labels
No labels