inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.02k stars 405 forks source link

Deep merge props from partial reloads #1877

Closed lepikhinb closed 1 month ago

lepikhinb commented 1 month ago

Deep merge props on partial visits instead of simple concatenation, to preserve deeply nested props that are not present in the partial response. Array values will be replaced with new values.

Introduces required changes for https://github.com/inertiajs/inertia-laravel/pull/620

Initial response:

{
  "user": {
    "id": 1,
    "name": "New user",
    "email": "boris@example.com"
  }
}

Partial request:

router.put(
  '/profile',
  {
    name: 'Boris Lepikhin'
  },
  {
    only: ['user.name'],
  }
)

Page props (auth.user.id preserved):

{
  "user": {
    "id": 1,
    "name": "New user",
    "email": "boris@example.com"
  }
}