0

I have 3 main pages like

/   
/signup
/dashboard  #on successfull login

The problem is that after login , user will be there on dashboard page /dashboard , The dashboard page has 2 main components

  1. side navigation menu
  2. inner Dashboard (divided the screen as two)

side nav has some links call users , organizations etc . when user clicks on that menu i want to display

 /dashboard/user , /dashboard/organisations

in inner dashboard without affecting the headers and side nav My App.Js File

 // Main App.js(Route file of react project)

<BrowserRouter>
    <Switch>
      <Route path="/" exact component={Login}/>
      <Route path="/signup" exact component={Signup}/>
      <PrivateRoute exact path="/dashboard" component={Dashboard}/>
     </Switch>
</BrowserRouter>

How Can I do that? Any Ideas . Thanks In Advance

Crypto Man
  • 32
  • 7
  • 1
    to clarify, your user is a user id or the text "user"? do you want to display both `` and `` under dashboard when a link is clicked in side navigation menu? – Joseph D. Nov 12 '20 at 08:14
  • actually i need /user/:id bt for test purpose i tried with /user...when user is clicked inner dashboard should show User component and when Organisation is clicked it should show organisation component in inner dashboard..not both at a time – Crypto Man Nov 12 '20 at 08:29
  • 1
    First you would need to add an optional parameter to your dashboard path => path="/dashboard/:route" (replace ":route" with your preferred name). Then in the dashboard you can get the 'route' parameter from props.match.params.route. – Jan-Philipp Marks Nov 12 '20 at 08:30
  • 1
    Can you show the Link tags you are using to navigate from your side menu? – Jan-Philipp Marks Nov 12 '20 at 08:31
  • Organisation User – Crypto Man Nov 12 '20 at 08:40
  • @jpmarks when user click on user tab the url will be /dashboard/user so as you told in inner dashboard i write {props.match.params.route==="organisaion" && } so it works !!!! Thank You So much for the idea, however am still looking for if i can do it with normal routes – Crypto Man Nov 12 '20 at 08:56
  • Why do you want to do it with normal routes? If you define both routes or have one varibale parameter, doesnt make much of a difference if you are trying to reuse the same component and page. – Jan-Philipp Marks Nov 13 '20 at 07:33

0 Answers0