score:3

Accepted answer

the usegatracker hook is being used outside the browserrouter so there is no routing context above it in the reacttree.

to resolve, move the router to the component rendering app so there's a provided routing context. this may likely be the index.js file. (you'd typically wrap app with the authprovider here as well)

example:

... other imports ...
import { browserrouter as router } from 'react-router-dom';
import { authprovider } from "./context/authcontext"

const rootelement = document.getelementbyid("root");
reactdom.render(
  <strictmode>
    <authprovider>
      <router>
        <app />
      </router>
    </authprovider>
  </strictmode>,
  rootelement
);

...

const app = () => {
  usegatracker(); // <-- has a routing context now!

  return (
    <>
      <helmet>
        <title>codingspace - learn by building web and mobile apps</title>
      </helmet>
      <div classname="relative grid min-h-screen md:grid-cols-layout-tablet xl:grid-cols-layout-desktop grid-rows-layout-desktop md:gap-6">
        <navbar />
        <sidebar />
        <switch>
          <suspense fallback={<div>loading..</div>}>
            <route exact path="/" component={dashboard} />
          </suspense>
        </switch>
        <feedback />
        <footer />
      </div>
    </>
  )
}

Related Query

More Query from same tag