Route Transitions
See original GitHub issueHow would I transition from one route to another after an action is performed? I have seen transitionTo() being used when a RouterContainer is created, but what is the equivalent in preact? I am also looking at securing a route until someone logs in. I have seen the following for React, is there also an equivalent for the following?
static willTransitionTo(transition, params, query, callback) {
if (!AuthStore.loggedIn()) {
// go over to login page
transition.redirect('/login', null, {
redirect: transition.path
});
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Transitions - Vue Router
In order to use transitions on your route components and animate navigations, ... If you want each route's component to have different transitions, ......
Read more >Route transition animations - Angular
When a user navigates from one route to another, the Angular router maps the URL path to a relevant component and displays its...
Read more >route_transitions | Flutter Package - Pub.dev
This package has been rewritten to use friendly route functions to navigate even with your favourite route transition and ability to build custom...
Read more >4 Awesome Examples of Vue Router Transitions - LearnVue
Vue Router transitions are a quick and easy way to add some flair to Vue app. They allow you to add smooth animations/transitions...
Read more >Animate a page route transition - Flutter documentation
This recipe shows how to transition between routes by animating the new route into view from the bottom of the screen. To create...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
To redirect, you can use the
route()
method. The staticwillTransitionTo
method from react-router is a little awkward (I believe they are looking at alternative ways to implement such things). My suggestion would be to use a high-order component that does the session check and conditionally renders the actual route component only if there is a valid session.Here’s a simple example:
Here’s a more complete example, using a generalized
<AuthenticatedRoute />
high order component to wrap a given route in an auth check like you described:Hey, thanks for fixing the issue.