简体   繁体   中英

React-Router-Dom `Link` changes route, but no component loads

I'm working with a react app, and I have the router setup, the issue is I currently have three components available to the user via the Link component and this is how those are in the jsx.

<Fragment>
    <NavItem>
       <Link to='/login'>Login</Link>
    </NavItem>
    <NavItem>
       <Link to="/regiser">Register</Link>
    </NavItem>
    <NavItem>
       <Link to="/reset">Recover Account</Link>
    </NavItem>
</Fragment>

and the routes are defined with BrowserRouter aliased to Router

<Fragment>
    <Route exact path='/' component={Landing} />
    <Route exact path='/register' component={Register} />
    <Route exact path='/login' component={Login} />
    <Route exact path='/reset' component={ResetUser} />
</Fragment>

The issue is this:

  1. The user is presented with Landing component when at /
  2. The user is presented with Login component when at /login
  3. The user is presented with ResetUser component when at /reset
  4. The user is not presented with a component at all when at /register

The Register component is defined like this:

import React, { Component, Fragment } from "react";

class Register extends Component {
    render() {
        return (
            <div>Hello Register</div>
        );
    }
}
export default Register;

which is infuriating because it's really holding me up for testing authentication.......

Is it the typo in regiser? it should be register!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM