简体   繁体   中英

goBack on multiple routes with 'react-router-dom'

For example, my browser history looks like this:

/page1 > /page2 > /page3 > /page4 > /page5

I want to navigate to /page2 from /page5, and then navigate to /page1 with history.goBack() function. I tried go(-3) , but it works just like push() . I need something like goBack(-3) or replace(-3) , or maybe there is another way?

These are the ways to redirect to the pages.

  1. props.histrory.push() // in push method you can pass routes specified in app

  2. Can use component called Redirect ex: <Redirect to={''} />

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