diff --git a/resources/js/Pages/merging-props.jsx b/resources/js/Pages/merging-props.jsx index e0a69084..1b429cf1 100644 --- a/resources/js/Pages/merging-props.jsx +++ b/resources/js/Pages/merging-props.jsx @@ -1,4 +1,4 @@ -import { A, Code, H1, H2, P, Strong, TabbedCode } from '@/Components' +import { A, Code, CodeBlock, H1, H2, Notice, P, TabbedCode } from '@/Components' import dedent from 'dedent-js' export const meta = { @@ -6,6 +6,8 @@ export const meta = { links: [ { url: '#top', name: 'Introduction' }, { url: '#server-side', name: 'Server side' }, + { url: '#client-side', name: 'Client side' }, + { url: '#combining-with-deferred-props', name: 'Deferred props' }, { url: '#resetting-props', name: 'Resetting props' }, ], } @@ -71,15 +73,34 @@ export default function () { ]} /> +
+ During the merging process, if the value is an array, the incoming items will be{' '}
+ appended to the existing array, not merged by index. However, you may chain the{' '}
+ matchOn method to determine how existing items should be matched and updated.
+
+ In this example, Inertia will iterate over the users.data array and attempt to{' '}
+ match each item by its id field. If a match is found, the existing item will be replaced.
+ If no match is found, the new item will be appended.
+
matchOn to specify multiple keys for matching.
+
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. -
+You can also combine deferred props with mergeable props to defer the loading of the prop and ultimately mark it as mergeable once it's loaded.