Reputation: 41
I'm trying to implement flash messages upon a redirect. I added
'flash' => [
'message' => fn () => $request->session()->get('message')
],
to the HandleInertiaRequests.php, and I have a simple Inertia link posting to a controller that redirects back as so
return \redirect()->back()->with('message', 'Item added successfully!');
On the front end there's just
<div v-if="$page.props.flash.message">{{$page.props.flash.message}}</div>
The problem is that the message appears for half a second or so, and then disappears. It's as though the page gets refreshed as soon as it changes.
Any ideas what might be causing this?
EDIT: turned out that the issue was with the dependency declaration in my package.json. I had
"@inertiajs/inertia": "^0.11.0",
whereas I got it working after npm install with
"@inertiajs/vue3": "^2.0.0",
Near as I can tell, the core issue this produced was that the $page object itself was undefined as usePage() wouldn't work despite its import being present.
Upvotes: 0
Views: 75