mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-21 00:35:55 +00:00
docs: update getCachedData types (#31208)
This commit is contained in:
parent
16e09391b9
commit
4d258e2b10
@ -74,7 +74,7 @@ The `handler` function should be **side-effect free** to ensure predictable beha
|
|||||||
- `transform`: a function that can be used to alter `handler` function result after resolving
|
- `transform`: a function that can be used to alter `handler` function result after resolving
|
||||||
- `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is:
|
- `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is:
|
||||||
```ts
|
```ts
|
||||||
const getDefaultCachedData = (key) => nuxtApp.isHydrating
|
const getDefaultCachedData = (key, nuxtApp) => nuxtApp.isHydrating
|
||||||
? nuxtApp.payload.data[key]
|
? nuxtApp.payload.data[key]
|
||||||
: nuxtApp.static.data[key]
|
: nuxtApp.static.data[key]
|
||||||
```
|
```
|
||||||
@ -141,7 +141,7 @@ type AsyncDataOptions<DataT> = {
|
|||||||
transform?: (input: DataT) => DataT | Promise<DataT>
|
transform?: (input: DataT) => DataT | Promise<DataT>
|
||||||
pick?: string[]
|
pick?: string[]
|
||||||
watch?: WatchSource[]
|
watch?: WatchSource[]
|
||||||
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT
|
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
type AsyncData<DataT, ErrorT> = {
|
type AsyncData<DataT, ErrorT> = {
|
||||||
|
@ -111,7 +111,7 @@ All fetch options can be given a `computed` or `ref` value. These will be watche
|
|||||||
- `transform`: a function that can be used to alter `handler` function result after resolving
|
- `transform`: a function that can be used to alter `handler` function result after resolving
|
||||||
- `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is:
|
- `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is:
|
||||||
```ts
|
```ts
|
||||||
const getDefaultCachedData = (key) => nuxtApp.isHydrating
|
const getDefaultCachedData = (key, nuxtApp) => nuxtApp.isHydrating
|
||||||
? nuxtApp.payload.data[key]
|
? nuxtApp.payload.data[key]
|
||||||
: nuxtApp.static.data[key]
|
: nuxtApp.static.data[key]
|
||||||
```
|
```
|
||||||
@ -174,7 +174,7 @@ type UseFetchOptions<DataT> = {
|
|||||||
server?: boolean
|
server?: boolean
|
||||||
lazy?: boolean
|
lazy?: boolean
|
||||||
immediate?: boolean
|
immediate?: boolean
|
||||||
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT
|
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT | undefined
|
||||||
deep?: boolean
|
deep?: boolean
|
||||||
dedupe?: 'cancel' | 'defer'
|
dedupe?: 'cancel' | 'defer'
|
||||||
default?: () => DataT
|
default?: () => DataT
|
||||||
|
Loading…
Reference in New Issue
Block a user