diff --git a/packages/react-query/src/QueryErrorResetBoundary.tsx b/packages/react-query/src/QueryErrorResetBoundary.tsx index ba5fe3b2be5..910215bcb6d 100644 --- a/packages/react-query/src/QueryErrorResetBoundary.tsx +++ b/packages/react-query/src/QueryErrorResetBoundary.tsx @@ -2,11 +2,14 @@ import * as React from 'react' // CONTEXT +export type QueryErrorResetFunction = () => void +export type QueryErrorIsResetFunction = () => boolean +export type QueryErrorClearResetFunction = () => void export interface QueryErrorResetBoundaryValue { - clearReset: () => void - isReset: () => boolean - reset: () => void + clearReset: QueryErrorClearResetFunction + isReset: QueryErrorIsResetFunction + reset: QueryErrorResetFunction } function createValue(): QueryErrorResetBoundaryValue { @@ -33,10 +36,12 @@ export const useQueryErrorResetBoundary = () => // COMPONENT +export type QueryErrorResetBoundaryFunction = ( + value: QueryErrorResetBoundaryValue, +) => React.ReactNode + export interface QueryErrorResetBoundaryProps { - children: - | ((value: QueryErrorResetBoundaryValue) => React.ReactNode) - | React.ReactNode + children: QueryErrorResetBoundaryFunction | React.ReactNode } export const QueryErrorResetBoundary = ({ @@ -45,9 +50,7 @@ export const QueryErrorResetBoundary = ({ const [value] = React.useState(() => createValue()) return ( - {typeof children === 'function' - ? (children as Function)(value) - : children} + {typeof children === 'function' ? children(value) : children} ) } diff --git a/packages/react-query/src/index.ts b/packages/react-query/src/index.ts index ee14798ba8f..5f372f4195e 100644 --- a/packages/react-query/src/index.ts +++ b/packages/react-query/src/index.ts @@ -38,6 +38,12 @@ export type { QueryClientProviderProps } from './QueryClientProvider' export type { QueryErrorResetBoundaryProps } from './QueryErrorResetBoundary' export { HydrationBoundary } from './HydrationBoundary' export type { HydrationBoundaryProps } from './HydrationBoundary' +export type { + QueryErrorClearResetFunction, + QueryErrorIsResetFunction, + QueryErrorResetBoundaryFunction, + QueryErrorResetFunction, +} from './QueryErrorResetBoundary' export { QueryErrorResetBoundary, useQueryErrorResetBoundary,