-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add NotFound component and 404 redirect #440
base: main
Are you sure you want to change the base?
Conversation
c4f22be
to
cc40c69
Compare
Since there is now a companion server pull request, I will take this out of draft. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious about whether this works with the MemoryRouter
, since you're directly modifying window.location
. Otherwise seems good.
height: "100%" | ||
}} | ||
> | ||
<Typography variant="h1" sx={{ fontSize: "18px", color: "#333" }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if now is the time to think about this, but do we have some global theme somewhere where these colors are stored? In the future we may want to support theming (so that we can integrate nicely with JupyterLab, among other reasons).
// useHref takes into account React Router basename option. So if basename is | ||
// set to "/conda-store", the hook will return "/conda-store/not-found" | ||
const url = useHref("/not-found"); | ||
window.location.replace(url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work when using MemoryRouter
?
Related to conda-incubator/conda-store#899
Description
The basic idea of this pull request is that if the app loads and the user is at some unknown route such as
/conda-store/foo/bar
, the app will forcefully redirect them to/conda-store/not-found
. This redirect should hit the server, which should return this React app along with a 404 HTTP status code. The app will in turn execute at this URL and render a "not found" page.This pull request:
history.pushState()
but an actual refresh of the browser page usingwindow.location.replace()
{urlBasename}/not-found
route matches.Pull request checklist