-
Notifications
You must be signed in to change notification settings - Fork 194
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
BUG: FlowRouter.reactiveCurrent() causes 2 run, when first time access #77
Comments
I want to make sure there is an
but first time |
Is the first run when the autorun is registered and the second one when FlowRouter has run and changed the value? What if you use Do this instead? var comp = Components.define('postDetail', function() {
this.autorun(function(computation) {
var id = FlowRouter.getParam('id');
if (!(computation.firstRun || id)) {
return FlowRouter.go('/');
}
console.log(id);
});
});``` |
I think I found the source of the problem in #95. If approved I'll generate a PR. It's about the order of storing the new values in the In your example above you're calling autorun and that is called immediately by FlowComponents here. I haven't used FlowComponents but I briefly looked at its docs and it seems we're supposed to write the components in a script file. So, is the example code you have above in a component script file? If so, then that code is run at app loading time, not in an Where is that call to |
Oh, I forgot to change code. It is exactly same as var comp = FlowComponents.define('postDetail', function() {
this.autorun(function() {
var id = FlowRouter.getParam('id');
if (!id) {
return FlowRouter.go('/');
}
console.log(id);
});
}); it called when access to page/route. |
Released version |
👍 |
When access directly (not clicking on anchor), autorun that includes
FlowRouter.reactiveCurrent()
, runs two times. Ideally, it should be run once.The text was updated successfully, but these errors were encountered: