Skip to content
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

Better specify "not found" behavior #20

Closed
mjackson opened this issue Jun 9, 2014 · 2 comments
Closed

Better specify "not found" behavior #20

mjackson opened this issue Jun 9, 2014 · 2 comments

Comments

@mjackson
Copy link
Member

mjackson commented Jun 9, 2014

Currently, when none of the routes in a router match the URL, the router sets its top-level props to null which effectively removes everything below it from the DOM. It would be nice in these instances to let users provide a "not found" handler that can essentially show a 404 page. We would only need one such handler per router.

Perhaps the existing API could be altered to include this?

<Route notFound handler={NotFound}/>

@rpflorence thoughts?

@mjackson
Copy link
Member Author

The more I think about this, the more I'm convinced that we don't really need a NotFound handler. Instead, it really comes down to how Router#transitionTo is being called.

If a user is calling transitionTo directly on a Router instance, and the router can't match on the given path, we should throw. Plain as that.

If we're calling transitionTo automatically from a URL change and the router can't match on the current URL, we could print a warning to the console and just leave the state of the router as it is. The next time the URL changes to something that router does recognize, it will update accordingly.

mjackson added a commit that referenced this issue Jun 10, 2014
This may not be a complete solution to #20, but it's better than
just showing nothing on the page and no error in the console to
indicate why.
@mjackson
Copy link
Member Author

I removed the Router#transitionTo API entirely, so this is no longer an issue.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant