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
Hooks called twice on every rendering ? Error or "Feature" ? #1031
Comments
I've also noticed this with |
Maybe my problem will be fixed when adding if (!this.ready()) return; at the top of the hooks to prevent, that the hoock will be do what it should when not be ready. I will test this later and update the status. // But this just will ( I think so ?) work with onAfterAction and NOT for onBeforeAction. |
Can someone post a reproduction I can quickly run and look at? My expectation is that the entire route is run in a computation. But the computation will only rerun if something invalidates it. |
@cmather What do you need exactly as reproduction? I'm having the same issue but I don't know what to send you. |
Hi @ndemoreau, a link to a github repository that has code I can download and run. The code should be as simple as possible and demonstrate some unexpected behavior you're seeing. For example, you might have a route with a waitOn option and console.log. Then you would say in a comment, "I'm expecting this to run once but it's running twice". Does that make sense? In general, all of these functions are run inside a Tracker.autorun which creates a computation that can be invalidated and rerun at any time. So if you have something like a Mongo query inside one of the route functions, or you use |
did anyone solf this? i have the same issue... |
No idea why but multiply:iron-router-progress is causing this. Removed it and the hook isn't called anymore @cmather @ndemoreau |
i am doing it this nasty way : (any suggestions) |
@cmather Hi Chris, I have reproduced the error. Here is the Github repo. And you can test the problem here. Right on the homepage, just open the browser console and you will notice that Let me know if I can help. I also posted a StackOverflow question regarding this. |
I have seen this aswell. Is there some resolution to this? |
+1
|
IR hooks are run reactively, so if there are any reactive data sources, like |
My workaround (for now?) is similar to what @ahmadthd suggested:
|
Like @advany I removed multiply:iron-router-progress and the problem of the action being called twice went away. So it seems to be related to that package. The problem is I would like to actually use that package. I might file a bug with them. Also thanks to @alochschied for |
I switch the flow router |
Hey!
I switched from an older version to version 1.0 and now I have the problem that the Hooks called twice. Here is an example of what I mean:
This is my code for one route:
After running this route directly OR when clickung on a link which is "linking" to this route the console has this output:
As you can see the onBeforeAction and also the OnAfterAction is always called twice.
I made a "test": When removing the "if (this.ready()) [...]" Block the Hooks are just called once per running ... so the this.ready() seems to be the problem ... but then I do not rly understand how to use this in the right way ?
The text was updated successfully, but these errors were encountered: