* 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)
| 316 | * @param info - The hydrated resource value, which carries the query's `hydrationData`. |
| 317 | */ |
| 318 | onHydrated(_k, info) { |
| 319 | if (info.value && 'hydrationData' in info.value) { |
| 320 | hydrate(client(), { |
| 321 | // @ts-expect-error - hydrationData is not correctly typed internally |
| 322 | queries: [{ ...info.value.hydrationData }], |
| 323 | }) |
| 324 | } |
| 325 | |
| 326 | if (unsubscribe) return |
| 327 | /** |
| 328 | * Do not refetch query on mount if query was fetched on server, |
| 329 | * even if `staleTime` is not set. |
| 330 | */ |
| 331 | const newOptions = { ...initialOptions } |
| 332 | if ( |
| 333 | (initialOptions.staleTime || !initialOptions.initialData) && |
| 334 | info.value |
| 335 | ) { |
| 336 | newOptions.refetchOnMount = false |
| 337 | } |
| 338 | // Setting the options as an immutable object to prevent |
| 339 | // wonky behavior with observer subscriptions |
| 340 | observer().setOptions(newOptions) |
| 341 | setStateWithReconciliation(observer().getOptimisticResult(newOptions)) |
| 342 | unsubscribe = createClientSubscriber() |
| 343 | }, |
| 344 | }, |
| 345 | ) |
| 346 |
nothing calls this directly
no test coverage detected