navigate({ to: -1 }) push a new state does not make sense?
Describe the bug
navigate({ to: -1 }) would push a new stack does not make sense.
I expect its behavior should be like history.go(-1)
Your Example Website or App
https://stackblitz.com/edit/react-ts-z9a1mv?file=style.css,App.tsx
Steps to Reproduce the Bug or Issue
- Click link navigate to
/posts. - Click any link navigate to
/posts/:id.
Now,
(a). click button which navigate({to: ".."}) then back to /posts, then click navigate({to: ".."}) again, nothing happened. (why? Or this is a bug?)
(b). click button which navigate({to: -1}) then navigate to /posts/:id/-1. (confusing)
(c). click button which Layout: navigate({ to: '..' }) then back to /. Why the behavior is different with (a)?
(d). click button which Layout: history.go(-1) then back to /posts, click again then back to /. this behavior is expected. But it use useLocation hook which is not list in documentation API references.
The four cases mentioned above have different behavior make people comfusing.
So, what's the recommended way to do like history.go()?
Expected behavior
Pass a number to navigate() should be like history.go()
Screenshots or Videos
No response
Platform
- OS: macOS Monterey 12.4
- Browser: Chrome
- Version: 101.0.4951.64
Additional context
No response