Let's say I want to flash a message in the layout for the users. I do it by adding this value to the session as $request->session()->flash('message', 'Hello'); and then either use it as shared data or I pass it manually to some of my pages props.
The problem is all of these solutions make the message persist the history navigation. What I mean is that if I go back in history and then go forward again, the message would appear again, as the props are part of the history data.
Is there any fancy built-in way to prevent the flashed message from being displayed again after going back and forward in history?
@mes do you know if this can be done without manually closing the message? I'd like to somehow clear the data without "reloading" the route. My guess is that the only way to do that would be through history.replaceState() internally, but I'm not sure if there's any Inertia's helper for that.
@beartown use JS. Add a state variable like errorVisible. When it's false, don't render the error element. You can set the variable to true when you get a new error, and use setTimeout to set it to false after a delay.
@JussiMannisto no, it's about making sure that this message is no longer rendered from the history state. It has nothing to do with the app state itself. You won't update history via changing state anyway.