mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-20 00:11:18 +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
|
||||
- `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is:
|
||||
```ts
|
||||
const getDefaultCachedData = (key) => nuxtApp.isHydrating
|
||||
const getDefaultCachedData = (key, nuxtApp) => nuxtApp.isHydrating
|
||||
? nuxtApp.payload.data[key]
|
||||
: nuxtApp.static.data[key]
|
||||
```
|
||||
@ -141,7 +141,7 @@ type AsyncDataOptions<DataT> = {
|
||||
transform?: (input: DataT) => DataT | Promise<DataT>
|
||||
pick?: string[]
|
||||
watch?: WatchSource[]
|
||||
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT
|
||||
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT | undefined
|
||||
}
|
||||
|
||||
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
|
||||
- `getCachedData`: Provide a function which returns cached data. A `null` or `undefined` return value will trigger a fetch. By default, this is:
|
||||
```ts
|
||||
const getDefaultCachedData = (key) => nuxtApp.isHydrating
|
||||
const getDefaultCachedData = (key, nuxtApp) => nuxtApp.isHydrating
|
||||
? nuxtApp.payload.data[key]
|
||||
: nuxtApp.static.data[key]
|
||||
```
|
||||
@ -174,7 +174,7 @@ type UseFetchOptions<DataT> = {
|
||||
server?: boolean
|
||||
lazy?: boolean
|
||||
immediate?: boolean
|
||||
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT
|
||||
getCachedData?: (key: string, nuxtApp: NuxtApp) => DataT | undefined
|
||||
deep?: boolean
|
||||
dedupe?: 'cancel' | 'defer'
|
||||
default?: () => DataT
|
||||
|
Loading…
Reference in New Issue
Block a user