( options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, )
| 936 | } |
| 937 | |
| 938 | function getDefaultState< |
| 939 | TQueryFnData, |
| 940 | TError, |
| 941 | TData, |
| 942 | TQueryKey extends QueryKey, |
| 943 | >( |
| 944 | options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>, |
| 945 | ): QueryState<TData, TError> { |
| 946 | const data = |
| 947 | typeof options.initialData === 'function' |
| 948 | ? (options.initialData as InitialDataFunction<TData>)() |
| 949 | : options.initialData |
| 950 | |
| 951 | const hasData = data !== undefined |
| 952 | |
| 953 | const initialDataUpdatedAt = hasData |
| 954 | ? typeof options.initialDataUpdatedAt === 'function' |
| 955 | ? options.initialDataUpdatedAt() |
| 956 | : options.initialDataUpdatedAt |
| 957 | : 0 |
| 958 | |
| 959 | return { |
| 960 | data, |
| 961 | dataUpdateCount: 0, |
| 962 | dataUpdatedAt: hasData ? (initialDataUpdatedAt ?? Date.now()) : 0, |
| 963 | error: null, |
| 964 | errorUpdateCount: 0, |
| 965 | errorUpdatedAt: 0, |
| 966 | fetchFailureCount: 0, |
| 967 | fetchFailureReason: null, |
| 968 | fetchMeta: null, |
| 969 | isInvalidated: false, |
| 970 | status: hasData ? 'success' : 'pending', |
| 971 | fetchStatus: 'idle', |
| 972 | } |
| 973 | } |
no outgoing calls
no test coverage detected