next-router-mock
next-router-mock copied to clipboard
`router.back` support
If router.back was supported, what kind of use-case would you want? Like, maybe push should keep a stack of URLs, and router.back would pop from the stack? Any other scenarios to support?
If
router.backwas supported, what kind of use-case would you want? Like, maybepushshould keep a stack of URLs, androuter.backwould pop from the stack? Any other scenarios to support?
In my case, I implement a react hook that is based on the next-router. And When you type something wrong. It will force redirect the page to the expected main page, which uses router.replace. But most cases, it will use router.push to track the user's history.
That's why I need router.back because I want to see if the browser history is working as expected.
If
router.backwas supported, what kind of use-case would you want? Like, maybepushshould keep a stack of URLs, androuter.backwould pop from the stack? Any other scenarios to support?In my case, I implement a react hook that is based on the next-router. And When you type something wrong. It will force redirect the page to the expected main page, which uses
router.replace. But most cases, it will userouter.pushto track the user's history.That's why I need
router.backbecause I want to see if the browser history is working as expected.
https://github.com/toeverything/AFFiNE/blob/67df422d60a7e42f3287110d6fcdb5a2d515612a/apps/rem/src/hooks/tests/use-router-helper.spec.ts#L52-L55
I will try to work on this recently