@tanstack/react-query
Version:
Hooks for managing, caching and syncing asynchronous and remote data in React
29 lines (26 loc) • 924 B
JavaScript
'use client';
import * as React from 'react';
import { shouldThrowError } from './utils.esm.js';
const ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
if (options.suspense || options.useErrorBoundary) {
// Prevent retrying failed query if the error boundary has not been reset yet
if (!errorResetBoundary.isReset()) {
options.retryOnMount = false;
}
}
};
const useClearResetErrorBoundary = errorResetBoundary => {
React.useEffect(() => {
errorResetBoundary.clearReset();
}, [errorResetBoundary]);
};
const getHasError = ({
result,
errorResetBoundary,
useErrorBoundary,
query
}) => {
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && shouldThrowError(useErrorBoundary, [result.error, query]);
};
export { ensurePreventErrorBoundaryRetry, getHasError, useClearResetErrorBoundary };
//# sourceMappingURL=errorBoundaryUtils.esm.js.map