0

In my code, I want Header & Footer components to be rendered in all routes except '/login'so how to do that? How to hide component on a specific route?

const AppRouter = () => {
  return (
    <BrowserRouter>
      <div>
        <Header />
        <Switch>
          <Route path="/login" component={Login} /> {/* I wanna render this route without Header & Footer */}
          <Route path="/" component={Home} exact />
          <Route path="/product" component={ProductOverview} />
          <Route path="/profile" component={Profile} />
          <Route component={NotFound} />
        </Switch>
        <Footer />
      </div>
    </BrowserRouter>
  );
};
A.Usama
  • 157
  • 2
  • 8
  • Does this answer your question? [How to hide navbar in login page in react router](https://stackoverflow.com/questions/47281850/how-to-hide-navbar-in-login-page-in-react-router) – bertdida Aug 27 '20 at 01:10
  • @bertdida It is useful thank u! but it 404 Not found component doesn't work well by implementing this solution. – A.Usama Aug 27 '20 at 01:41

0 Answers0