elgorditosalsero / react-gtm-hook

Easily manage the Google Tag Manager via Hook
https://elgorditosalsero-react-gtm-hook.netlify.app/
MIT License
220 stars 28 forks source link

fix(strictmode): Fix for React in StrictMode causing a duplicate script registration #87

Open jafin opened 1 month ago

jafin commented 1 month ago

fix (StrictMode): Fix issue where google script will be injected twice in StrictMode due to InitGTM being fired twice and the script operation just appending to the dom

In theory InitGTM could just be a noop if the script already exists, but I am unsure if there is scope for a script to be reregistered for some reason, hence the delete/add approach.