Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Atef95's avatar

Inertia JS reactivity issue

Hi everyone , I'm trying to get the updated data after redirection in InertiaJs but I keep getting the old data..

This is my code Home Page :

    public function showDashboard()
    {
        return Inertia::render('Community/ShowDashboard', [
            'latestView' => $this->views->latestView(),
            'views' => $this->views->fetch('all'),
            'filters' => $this->filters->fetch('all'),
        ]);

    }

Submitting form

   public function handleCreateView(CreateView $request)
    {

        $this->views->store($request->validated());
        return Redirect::back()->with('success', 'View created!');

    }

Props and data in component

     props: ["latestView", "views", "filters"],

  data() {
    return {
      viewToEdit: false,
      selectedView: this.latestView,
      selectedViewName: this.latestView ? this.latestView.name : "No name",
      query: null,
    };
  },

The props are updating correctly in redirect but the attributes in data object are not!!

Why this is happening ?

Thanks!

0 likes
1 reply
carbontwelve's avatar

I know this is a year old, but for others who like myself found your question to be the first search result the answer is in my case and most likely yours is that Inertia.js preserves state for all requess other than GET as per their documentation here: https://inertiajs.com/manual-visits#state-preservation it took me a good hour of searching around before I stumbled upon that section of the docs.

For example:

form.submit(
      'post',
      'https://example.com',
      {
            preserveState: false,
      }
  );

Please or to participate in this conversation.