-
-
Notifications
You must be signed in to change notification settings - Fork 235
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
Router events runs multiple times. #583
Comments
How are you calling your layout? It’s looks like the layout setup is running with each page load, this is to be expected if your layout isn’t persistent. |
In DEV mode maybe it's ok because everything runs twice... |
This is an example of my index page that uses the Layout component: const props = usePage().props;
Pretty much the out of the box way of loading the DeveloperLayout. The DeveloperLayout is just the default Layout component renamed. |
I just tested in production mode. The issue is the same. |
Try following the instructions for Persistent Layouts instead of wrapping your layout around your page. The way you've done it, the layout is unmounted and then re-mounted every single time you navigate. This is likely causing the event listener to be registered multiple times. |
When i'm using the Inertia Router start event, all previous events gets logged too.
I'm using the following code:
This code is running in the main Layout, so it shouldn't be loaded more than once.
The purple box on the image is the console output when i click any link first time, the red box is when i click it the second time (i get both previous event and current event) and if i click it again it will continue like that (recursively).
Is this a bug, or am i doing it wrong?
The text was updated successfully, but these errors were encountered: