* If this resource was populated on the server (either sync render, or streamed in over time), onHydrated * will be called. This is the point at which we can hydrate the query cache state, and setup the query subscriber. * * Leveraging onHydrated allows us to plug into the async
(_k, info)
| 283 | * Note that this is only invoked on the client, for queries that were originally run on the server. |
| 284 | */ |
| 285 | onHydrated(_k, info) { |
| 286 | if (info.value && 'hydrationData' in info.value) { |
| 287 | hydrate(client(), { |
| 288 | // @ts-expect-error - hydrationData is not correctly typed internally |
| 289 | queries: [{ ...info.value.hydrationData }], |
| 290 | }) |
| 291 | } |
| 292 | |
| 293 | if (unsubscribe) return |
| 294 | /** |
| 295 | * Do not refetch query on mount if query was fetched on server, |
| 296 | * even if `staleTime` is not set. |
| 297 | */ |
| 298 | const newOptions = { ...initialOptions } |
| 299 | if ( |
| 300 | (initialOptions.staleTime || !initialOptions.initialData) && |
| 301 | info.value |
| 302 | ) { |
| 303 | newOptions.refetchOnMount = false |
| 304 | } |
| 305 | // Setting the options as an immutable object to prevent |
| 306 | // wonky behavior with observer subscriptions |
| 307 | observer().setOptions(newOptions) |
| 308 | setStateWithReconciliation(observer().getOptimisticResult(newOptions)) |
| 309 | unsubscribe = createClientSubscriber() |
| 310 | }, |
| 311 | }, |
| 312 | ) |
| 313 |
nothing calls this directly
no test coverage detected
searching dependent graphs…