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