简体   繁体   中英

React router: Route not working

I am in a component whose URL is

http://localhost:3000/dashboard/profile/timeline/abcd

and the route is set up as

<Route path="/dashboard/profile/:screenId/:userId" component={this.Routing}/>

When I go to a different profile for eg

http://localhost:3000/dashboard/profile/timeline/xyz

It is not routing but the url is changing

Any suggestion would be helpful

replace component={this.Routing} with component={Routing}

<Route exact path="/dashboard/profile/:screenId/:userId" component={Routing}/>

React : difference between <Route exact path="/" /> and <Route path="/" />

if your problem not resolve use Switch I have this problem too and i resolve with Switch

import {BrowserRouter, Route, Switch} from "react-router-dom";
.
.
.
.

        <BrowserRouter>
          <Switch>
              <Route exact key="1" path="/dashboard/profile/:screenId/:userId" component={Routing}/>
          </Switch>
        </BrowserRouter>

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