Open Kamaropoulos opened 7 years ago
Defining a route using the following code:
Router.route('/', () => { this.render('myTemplate'); });
will print an error in the console:
Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?
while the same code but with a regular function callback will work as expected:
Router.route('/', function() { this.render('myTemplate'); });
I know that the default way to define routes is with regular functions but shouldn't this theoretically work?
No, because render is attached to this which is bound when using an arrow function. i.e. an arrow function won't get the special this context that iron-router gives to the route handlers.
render
this
Defining a route using the following code:
will print an error in the console:
while the same code but with a regular function callback will work as expected:
I know that the default way to define routes is with regular functions but shouldn't this theoretically work?