Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding route for login #6

Closed
4 tasks done
piyush97 opened this issue Mar 15, 2019 · 2 comments · Fixed by #14
Closed
4 tasks done

Adding route for login #6

piyush97 opened this issue Mar 15, 2019 · 2 comments · Fixed by #14
Labels
help wanted Extra attention is needed

Comments

@piyush97
Copy link

!!! IF YOU DO NOT USE THIS ISSUES TEMPLATE, YOUR ISSUE IS LIABLE TO BEING IGNORED BY US

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed
  • I'm reporting the issue to the correct repository (for multi-repository projects)

Unexpected Behavior

Not able to create a route for Login

@einazare
Copy link
Contributor

Hello there @piyush97 ,

Please detail. What were the steps that you have taken, and they didn't work?

Best,
Manu

@einazare einazare added the help wanted Extra attention is needed label Mar 15, 2019
@j14y
Copy link

j14y commented Aug 8, 2019

In the index.js file in the src/ directory, ReactDOM.render is defined as:

ReactDOM.render(
  <Router history={hist}>
    <Switch>
      <Route path="/admin" render={props => <AdminLayout {...props} />} />
      <Route path="/rtl" render={props => <RTLLayout {...props} />} />
      <Redirect from="/" to="/admin/dashboard" />
    </Switch>
  </Router>,
  document.getElementById("root")
);

By default the dashboard redirects to /admin/dashboard when the root url / is entered.

If you want to implement a login/sign-up page, simply change

<Redirect from="/" to="/admin/dashboard" />

to something like

<Redirect from="/" to "/login"/>

You'll then have to supply a new route and component to react-router-dom, giving something like:

<Route path="/login" component={Login}/>

Where Login is your login view that you want create.

The final code looks like this:

ReactDOM.render(
  <Router history={hist}>
    <Switch>
      <Route path="/admin" render={props => <AdminLayout {...props} />} />
      <Route path="/rtl" render={props => <RTLLayout {...props} />} />
      <Route path="/login" component={Login}/>    {/* basically add this line */}
      <Redirect from="/" to="/login" /> {/* and change this line from the default */}
    </Switch>
  </Router>,
  document.getElementById("root")
);

Note that the file routes.js is used for specifying routes within the dashboard sidebar, so unless you want to add another view to it, it shouldn't be used for creating custom routes.

einazare added a commit that referenced this issue Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants