question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

route.current('..') not updating with inertia.js

See original GitHub issue

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

<li class="mainSidebar__rightListItem" 
:class="{ 'mainSidebar__rightListItem--active': route().current('dashboard*') }"
></li>

Ziggy configuration

embedded in blade view of laravel

Route definition

Route::get('/dashboard', [
    DashboardController::class,
    'index',
])->middleware('auth:web')->name('dashboard');

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

5reactions
ta369ecommented, Jun 9, 2021

I found out why. route().current('dashboard*') was accessed in a child component of the layout, I had to pass route().current() as property to the child component to solve it. @bakerkretzmar

1reaction
madsh93commented, Sep 1, 2022

@madsh93 try listening for Inertia’s navigate event maybe? https://inertiajs.com/events#navigate

Haha funny! I was just doing that and was about to post the solution. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inertia - Ziggy route().current() is undefined - Laracasts
I have installed a fresh laravel 8 project, scaffolded auth with jetstream using Inertia and have then added Ziggy to work with Laravel's...
Read more >
Routing - Inertia.js
With Inertia all routing is defined server-side. Meaning you don't need Vue Router or React Router. Simply create routes using your server-side framework...
Read more >
laravel - Inertia get request does not update $page.props
My problem is, that the code Inertia.get(route("home"), { q: query }, {preserveState: false}); does not update the vue 3 state.
Read more >
The Ultimate Guide to Inertia.js - Kinsta
A look at how Inertia.js makes constructing single-page applications a piece of cake, while solving other problems for developers.
Read more >
Using Ziggy with Inertia Server-Side Rendering - Aaron Francis
To see a fully working Laravel Jetstream + Inertia + Ziggy + Sidecar SSR demo repo ... ziggy: path.resolve('vendor/tightenco/ziggy/src/js'),.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found