Replies: 1 comment 1 reply
-
This StackOverflow answer seems pretty comprehensive, but it was posted in 2016 - I wonder if there isn't something new since then? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all, massive react-router noob here,
Let's say I'd like to have the following routes:
example.com/
: The top-level landing pageexample.com/about
: The about sectionexample.com/login
: The login pageNow, assuming that the user first accesses
example.com/
, then there's absolutely no problem for React router to then send the user to the virtual routeabout
(Say, there's a button on the top-level landing page that takes them there.)But now, imagine that the
about
page is super useful, and a user bookmarks it. So then, when they open a fresh tab and try to navigate toexample.com/about
, ofcourse theGET
request will try to get at theabout/
resource, which ofcourse doesn't actually exist, and the user gets a 404.I would really like to get something like this to work - I'm aware there are "hacks" like the hash routing stuff where you can do
example.com/#/about
, etc.But I actually noticed, that the React routed documentation pages seem to implement this feature! E.g., if I click that link, and start clicking on random pages in the sidebar, I can see in my
Network
tab entries likeBut then, if I try to access for example, the
https://reactrouter.com/en/6.6.0/fetch/json
page directly, that then goes on and actually does a realGET
request for the specific resource, i.e. I see in myNetwork
tabI'd love to know how replicate this "dual-use" setup - I mean, I can both navigate to whatever page I want via React Router (and its super fast, because its really just an SPA that fiddles with your browser history), but I can also go directly to the URL I want, and that works too.
Beta Was this translation helpful? Give feedback.
All reactions