Replies: 3 comments
-
Also see #78 for a previous discussion :) |
Beta Was this translation helpful? Give feedback.
-
Hey @AdrianMrn I use a custom composable for notifications / flash messages within an Inertia application. Some time ago I used import { Inertia } from '@inertiajs/inertia';
import { useNotifications } from './composables';
Inertia.on('success', event => {
const props = event.detail?.page?.props ?? {};
if (props.notification) {
useNotifications().add(props.notification);
delete props.notification;
}
}); |
Beta Was this translation helpful? Give feedback.
-
@ajnsn Your answer didn't do it for me, but it seems I was incorrectly setting the new state in my first example. I was supposed to use history.replaceState(
{ ...history.state, props: { ...history.state.props, flash: null } },
'',
window.location.href
); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to overwrite or clear a page prop that was set from Inertia PHP?
We submit our forms using Inertia, so we receive our flash messages with error messages from the Inertia page props. After getting a flash message, navigating to another page, and pressing the browser's back button, I'd like to stop the flash message from appearing again.
I'm using the React integration of InertiaJS.
I tried
window.history.state.props.flash = null;
andBeta Was this translation helpful? Give feedback.
All reactions