react-router-example icon indicating copy to clipboard operation
react-router-example copied to clipboard

can please provide example with PrivateRoute with Menu

Open SomnathKadam opened this issue 4 years ago • 1 comments

Hi, Thanks for providing example,

can please provide example with PrivateRoute with Menu, which will not re-render menu

SomnathKadam avatar Jul 24 '20 14:07 SomnathKadam

Hi,

Can you elaborate more on your request?

If you wanna have a navigation menu, you can put inside the BrowserRouter, then when you change the Route, the Menu won't be re-render.

<BrowserRouter>
     <Menu />
      <Switch>
          <PublicRoute restricted={false} component={Home} path="/" exact />
          <PublicRoute restricted={true} component={SignIn} path="/signin" exact />
          <PrivateRoute component={Dashboard} path="/dashboard" exact />
      </Switch>
</BrowserRouter>

binhtran04 avatar Jul 28 '20 19:07 binhtran04