Uncaught TypeError: useContext(...) is undefined

Solution 1:

I think the issue is with useRouteMatch which requires the Router context (which in your case is defined in the same component and therefore not accessible).

Instead of useRouteMatch try the following:

<Switch>
  <Route path="/">
    <Home />
  </Route>
  <Route path="/about">
    <About />
  </Route>
  <Route path="/users">
    <Users />
  </Route>
</Switch>

Check out the react-router for a more detailed documentation.