Skip to content

Allow deepMerge on custom properties #2344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2025

Conversation

mpociot
Copy link
Contributor

@mpociot mpociot commented May 13, 2025

This PR is the JS counterpart of inertiajs/inertia-laravel#732

For whatever reason, the tests did time out when I tried to run them via npx for my newly created API route. I did test it manually by running the server though.
Not really sure what I did wrong.

@HichemTab-tech
Copy link
Contributor

HichemTab-tech commented May 13, 2025

For whatever reason, the tests did time out when I tried to run them via npx for my newly created API route. I did test it manually by running the server though.
Not really sure what I did wrong.

Happened to me too in a previous PR, i just kept running the tests until it worked, i think we should increase the timeout a bit.

@pascalbaljet
Copy link
Contributor

Thanks @mpociot, this looks great! I'll add another test for props with multiple strategies. I expect you added support for this if you have resources like this:

$data = [
    'users' => [
        ['id' => 1, 'name' => '...'],
        ['id' => 2, 'name' => '...'],
    ],
    'companies' => [
        ['id' => 1, 'name' => '...'],
        ['id' => 2, 'name' => '...'],
    ],
];

Inertia::render('Dashboard', [
    'results' => Inertia::deepMerge($data, ['users.id', 'companies.id']),
]);

@pascalbaljet pascalbaljet merged commit 31c01ef into inertiajs:master Jun 13, 2025
6 checks passed
@pascalbaljet
Copy link
Contributor

Updated the test in bdc5ef6 to test multiple arrays with different keys and unique keys. Thanks again!

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