From c546c41009618ac9bd42ce81fc3ff0d87a593c39 Mon Sep 17 00:00:00 2001 From: Joshua Chen Date: Mon, 16 May 2022 12:55:02 +0800 Subject: [PATCH] fix comment --- packages/docusaurus-plugin-google-gtag/src/gtag.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/docusaurus-plugin-google-gtag/src/gtag.ts b/packages/docusaurus-plugin-google-gtag/src/gtag.ts index a6e82b419aa0..2122511126a8 100644 --- a/packages/docusaurus-plugin-google-gtag/src/gtag.ts +++ b/packages/docusaurus-plugin-google-gtag/src/gtag.ts @@ -16,10 +16,9 @@ const clientModule: ClientModule = { onRouteDidUpdate({location, previousLocation}) { if (previousLocation && location.pathname !== previousLocation.pathname) { // Normally, the document title is updated in the next tick due to how - // `react-helmet-async` updates it. - // We want to send to gtag the current document title so we use - // setTimeout to put the function on the callback stack to be executed - // on the next tick. + // `react-helmet-async` updates it. We want to send the current document's + // title to gtag instead of the old one's, so we use `setTimeout` to defer + // execution to the next tick. // See: https://github.com/facebook/docusaurus/issues/7420 setTimeout(() => { // Always refer to the variable on window in case it gets overridden