1
votes

In my React project, I have:

  1. A Login component without header & sidebar components login image
  2. A Dashboard component with a header, a footer and other child components that all render within the dashboard component dashboard image
  3. An Error page component

Question: How should I construct my router to start from the login page and when I click on login, the router takes me to the dashboard?

1
Possible duplicate of Confusion With React RouterNimesha Kalinga

1 Answers

0
votes

I can point you to a nice medium article that also helped me to understand react routing. https://medium.com/@pshrmn/a-simple-react-router-v4-tutorial-7f23ff27adf

For an example what i would do is

<Route path="/" component={LoginPage} />
<Route exact path="/dashboard" component={DashboardComponent} />
<Route path="/dashboard/something" component={AnotherComponent} />

Then inside that DashboardComponent you can add your header and sidebar. And also other components. If you need routes like

/dashboard/some_other_thing

You have to define the relevent inside the DashboardComponent