question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for route handling without requiring a `Component`

See original GitHub issue

At the moment, in order to handle navigation to a particular route by forwarding to one of several views depending on a certain condition, one needs to create a dummy Component and either annotate that with @Route, or use RouteConfiguration.setRoute(...) which also requires a Class<? extends Component>. Since there is no actual view that should be shown for this route, it shouldn’t be necessary to create a dummy component class which will also get instantiated at runtime.

Consider support for registering a route with custom navigation handling that doesn’t require a UI component.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Legiothcommented, May 11, 2021

On a conceptual level, what this might mean is that there are actions registered for different URL patterns. There are terminal actions such as rendering a component inside a parent layout, showing an error or doing an external redirect, as well as intermediate actions that just conditionally delegate to some other action or URL.

1reaction
HermanBovenscommented, May 10, 2021

That is indeed my use case: handling A URL and, depending on user’s permissions, forward/redirect to a specific route. Using a dummy Component works, but feels like a workaround.

Op ma 10 mei 2021 08:25 schreef Pekka Hyvönen @.***>:

Ok @HermanBovens https://github.com/HermanBovens - can you please provide more details on the use case you have and how this solves that ?

I would just use a dummy component for the registered route and then either forward to the correct route component to be showed or just add the correct component as the child component.

I’m speculating, but I guess what you’d want to do (?) is register some handler that is invoked for a certain route path and then it forwards to another route instead. Like for example a class with Route and implements a one method interface where it gets routing data and a callback to call to make the forward/redirect - which will give the router the component(s) that should be actually shown. And in case the callback is not invoked, then the 404 error page would be shown.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vaadin/flow/issues/10419#issuecomment-836239167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOVHA2RDDZNUC7EVCSMNTLTM5363ANCNFSM4ZZUSZEA .

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Handle Routing in React Apps with React Router
In this tutorial, you'll install and configure React Router, build a set of routes, and connect to them using the <Link> component.
Read more >
Routing - Express.js
Express Route Tester is a handy tool for testing basic Express routes, although it does not support pattern matching. Query strings are not...
Read more >
Express Tutorial Part 4: Routes and controllers - MDN Web Docs
In this tutorial we'll set up routes (URL handling code) with "dummy" ... and then adds a couple of routes to it using...
Read more >
React Router with optional path parameter - Stack Overflow
My question is, can we declare it in one route? If I add only the second row then the route without the parameter...
Read more >
How React Hooks can replace React Router - LogRocket Blog
import { Router, Route, Switch } from "react-router";. However, you should not install it directly into your project like that. If you're ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found