Skip to content

Commit 0c566ee

Browse files
committed
Document dot notation in partial reloads
1 parent c6df93d commit 0c566ee

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

docs/guide/partial-reloads.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ router.visit(url, {
4646

4747
## Except certain props
4848

49+
In addition to the only visit option you can also use the except option to specify which data the server should exclude. This option should also be an array of keys which correspond to the keys of the props.
50+
4951
:::tabs key:frameworks
5052
== Vue
5153

@@ -79,7 +81,53 @@ router.visit(url, {
7981

8082
:::
8183

82-
In addition to the only visit option you can also use the except option to specify which data the server should exclude. This option should also be an array of keys which correspond to the keys of the props.
84+
## Dot notation
85+
86+
Both the `only` and `except` visit options support dot notation to specify nested data, and they can be used together. In the following example, only `settings.theme` will be rendered, but without its `colors` property.
87+
88+
:::tabs key:frameworks
89+
== Vue
90+
91+
```js
92+
import { router } from '@inertiajs/vue3'
93+
94+
router.visit(url, {
95+
only: ['settings.theme'],
96+
except: ['setting.theme.colors'],
97+
})
98+
```
99+
100+
== React
101+
102+
```jsx
103+
import { router } from '@inertiajs/react'
104+
105+
router.visit(url, {
106+
only: ['settings.theme'],
107+
except: ['setting.theme.colors'],
108+
})
109+
```
110+
111+
== Svelte 4|Svelte 5
112+
113+
```js
114+
import { router } from '@inertiajs/svelte'
115+
116+
router.visit(url, {
117+
only: ['settings.theme'],
118+
except: ['setting.theme.colors'],
119+
})
120+
```
121+
122+
Please remember that, by design, partial reloading filters props _before_ they are evaluated, so it can only target explicitly defined prop keys. Let's say you have this prop:
123+
124+
`users: -> { User.all }`
125+
126+
Requesting `only: ['users.name']` will exclude the entire `users` prop, since `users.name` is not available before evaluating the prop.
127+
128+
Requesting `except: ['users.name']` will not exclude anything.
129+
130+
:::
83131

84132
## Router shorthand
85133

0 commit comments

Comments
 (0)