Closed ch-lukas closed 7 years ago
Hello @chluke123 ,
What is import(' .... eg dashboardPage');
exactly? Is this something what generated dynamically?
Note: import
, import()
and require()
can accept only string as argument, not a variable - only string. See #8717 , forum post, SO thread
Hi @dr-dimitru,
That was just a placeholder value for illustration. A real life example is return import('/imports/ui/pages/dashboard/navigation');
In the navigation folder is an index that loads the templates etc.
Routes all works well, except in the instance of the initial root redirect.
At first glance, it seems as if the Flowrouter.go redirect is bypassing the hooks of the route you want to go to.
Cheers
Okay, then does it work this way?:
Open.route('/', {
name: 'landingPage',
waitOn() {
return import('/imports/ui/pages/landing');
},
action() {
if (Meteor.userId()) {
FlowRouter.go('/dashboard');
} else {
this.render('landingLayout', 'landingPage');
}
}
});
Open.route('/dashboard', {
name: 'dashboard Page',
waitOn() {
return import(' .... eg dashboardPage');
},
action() {
this.render('dashboardLayout', 'dashboardPage');
}
});
It works - cheers!
And so does my alternate example above... but I have been working on the code since then :).
The one constant is to watch out for the combination of triggersEnter / waitOn route imports / redirects.
Maybe a quick note in the docs about the limitations of using the triggersEnter hook might help.
Cheers, L
Well triggersEnter
definitely isn't equal to waitOn
.
I'm glad it's solved.
Feel free to reopen it in case if the issue still persists on your end.
Please, support this project by:
Starting using Meteor 1.5 and this router to be able to get most out of dynamic imports and everything is working well... almost. Any suggestions?
When I redirect (e.g. if user is already logged-in, redirect from / to dashboard) I get a 'no such template' error and then even with the error the page loads up correctly.
Some background :
Tried these 2 options, but don't work
Alternative,