In the docs, we can find:
State preservation
…
You can instruct Inertia to preserve the component’s state when using the get
method by setting the preserveState
option to true
.
router.get('/users', { search: 'John' }, { preserveState: true })
…
I use this in my React application precisely for searching & filtering rows in, for example, a datatable.
For that, I have binded that search
string to a text input content, so changing it launches a GET request that, in turn, changes the URL, e.g. http://localhost/example?search=Johnny
. And because of that URL change, Inertia then always triggers a full page reload, making preserveState: true
option totally useless in my case…
How is the “search functionality” supposed to be implemented then? What am I failing at?
Thanks in advance.