Skip to content

Conversation

@skryukov
Copy link
Collaborator

@skryukov skryukov commented Apr 10, 2025

This PR adds support for deep merge props.

See inertiajs/inertia-laravel#679 and inertiajs/inertia#2069

@skryukov skryukov marked this pull request as ready for review April 10, 2025 08:25
## Server side

To specify that a prop should be merged, you can use the `merge` method on the prop value.
> `deep_merge` requires `@inertiajs/core` v2.1.0 or higher, and `inertia_rails` v3.8.0 or higher.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version numbers are subject to change 😂

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget it 😂 it's 2.0.8

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks @HichemTab-tech!

@skryukov skryukov changed the title Deep merge Deep merge props Apr 10, 2025
@skryukov skryukov force-pushed the deep-merge branch 2 times, most recently from 9e54c92 to 6288dcf Compare April 10, 2025 19:35
Copy link
Collaborator

@bknoles bknoles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great!

On the client side, Inertia detects that this prop should be merged. If the prop returns an array, it will append the response to the current prop value. If it's an object, it will merge the response with the current prop value.
On the client side, Inertia detects that this prop should be merged. If the prop returns an array, it will append the response to the current prop value. If it's an object, it will merge the response with the current prop value. If you have opted to `deepMerge`, Inertia ensures a deep merge of the entire structure.

**Of note:** During the merging process, if the value is an array, the incoming items will be _appended_ to the existing array, not merged by index.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good callout!

@bknoles bknoles merged commit b2e959e into inertiajs:master Apr 12, 2025
18 checks passed
@skryukov skryukov deleted the deep-merge branch April 12, 2025 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants