( options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, )
| 747 | } |
| 748 | |
| 749 | function getDefaultState< |
| 750 | TQueryFnData, |
| 751 | TError, |
| 752 | TData, |
| 753 | TQueryKey extends QueryKey, |
| 754 | >( |
| 755 | options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, |
| 756 | ): QueryState<TData, TError> { |
| 757 | const data = |
| 758 | typeof options.initialData === 'function' |
| 759 | ? (options.initialData as InitialDataFunction<TData>)() |
| 760 | : options.initialData |
| 761 | |
| 762 | const hasData = data !== undefined |
| 763 | |
| 764 | const initialDataUpdatedAt = hasData |
| 765 | ? typeof options.initialDataUpdatedAt === 'function' |
| 766 | ? options.initialDataUpdatedAt() |
| 767 | : options.initialDataUpdatedAt |
| 768 | : 0 |
| 769 | |
| 770 | return { |
| 771 | data, |
| 772 | dataUpdateCount: 0, |
| 773 | dataUpdatedAt: hasData ? (initialDataUpdatedAt ?? Date.now()) : 0, |
| 774 | error: null, |
| 775 | errorUpdateCount: 0, |
| 776 | errorUpdatedAt: 0, |
| 777 | fetchFailureCount: 0, |
| 778 | fetchFailureReason: null, |
| 779 | fetchMeta: null, |
| 780 | isInvalidated: false, |
| 781 | status: hasData ? 'success' : 'pending', |
| 782 | fetchStatus: 'idle', |
| 783 | } |
| 784 | } |
no outgoing calls
no test coverage detected