简体   繁体   中英

react routing this.props.history.push pathname is not working

My current link is http://localhost:3000/show/ .On this page i am using on video player component and after playing video link will generate like http://localhost:3000/video .But my expected result is http://localhost:3000/show/video . I am using

   this.props.history.push({
     pathname: this.props.match.url/video,
  });

and in route file i am using <Route path={ ${this.props.match.path}/Video } component={Video} /> but not routing video component. My expected result will http://localhost:3000/show/video

Try instead to use string templating to form a valid path string:

this.props.history.push({
  pathname: `${this.props.match.url}/video`,
});

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