-
Notifications
You must be signed in to change notification settings - Fork 247
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
route.current('..') not updating with inertia.js #433
Comments
what could prevent ziggy from updating |
Can you try moving |
I found out why. |
I'm using it in a layout, therefore not able to pass it as a prop. Do you know if it is possible to re-fetch current route again somehow? |
@madsh93 try listening for Inertia's |
Haha funny! I was just doing that and was about to post the solution. Thanks! |
Works only if there is no need to check id inside route. I have sidebar with multiple routes, so passing parameter route()->current() only looks for changes in route name, while I need watching route name and id param. I ended doing, any better option? Sidebar.vue:
Layout.vue:
Any better options? |
i think this may help
|
I have the same problem and I tried passing route().current() to the nested component but it had the same problem. I am thinking that this is related to my default persistent layout. I have confirmed this behaviour by removing persistent layouts and I will open a new issue. I am using a workaround in my HandleInertiaRequests middleware for the moment. |
I used Pinia as a workaround Here's my store file:
Listen to "navigate" event in your main file (my case the main layout), every time the event triggers, call the
Use like that in your components:
|
Yes, Pinia help me work around, and works well. Just save the route name to Pinia whenever the page is changing |
Ziggy version
^1.0
Laravel version
^8.38
Description
It was working fine but lately, I noticed that route.current() not updating on page visits, every time I have to refresh in order to get the right active route
Ziggy call and context
Ziggy configuration
Route definition
The text was updated successfully, but these errors were encountered: