( options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, )
| 711 | } |
| 712 | |
| 713 | function getDefaultState< |
| 714 | TQueryFnData, |
| 715 | TError, |
| 716 | TData, |
| 717 | TQueryKey extends QueryKey, |
| 718 | >( |
| 719 | options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, |
| 720 | ): QueryState<TData, TError> { |
| 721 | const data = |
| 722 | typeof options.initialData === 'function' |
| 723 | ? (options.initialData as InitialDataFunction<TData>)() |
| 724 | : options.initialData |
| 725 | |
| 726 | const hasData = data !== undefined |
| 727 | |
| 728 | const initialDataUpdatedAt = hasData |
| 729 | ? typeof options.initialDataUpdatedAt === 'function' |
| 730 | ? (options.initialDataUpdatedAt as () => number | undefined)() |
| 731 | : options.initialDataUpdatedAt |
| 732 | : 0 |
| 733 | |
| 734 | return { |
| 735 | data, |
| 736 | dataUpdateCount: 0, |
| 737 | dataUpdatedAt: hasData ? (initialDataUpdatedAt ?? Date.now()) : 0, |
| 738 | error: null, |
| 739 | errorUpdateCount: 0, |
| 740 | errorUpdatedAt: 0, |
| 741 | fetchFailureCount: 0, |
| 742 | fetchFailureReason: null, |
| 743 | fetchMeta: null, |
| 744 | isInvalidated: false, |
| 745 | status: hasData ? 'success' : 'pending', |
| 746 | fetchStatus: 'idle', |
| 747 | } |
| 748 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…