From 8e7928c43e3bfbd8956e3a33ff64a3075ac443ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Curley?= Date: Mon, 23 Sep 2024 15:36:18 +0100 Subject: [PATCH 1/2] feat(react-query): export QueryErrorResetBoundaryFunction Export the QueryErrorResetBoundaryFunction render prop function signature so users don't have to write wierd types of there own --- packages/react-query/src/QueryErrorResetBoundary.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-query/src/QueryErrorResetBoundary.tsx b/packages/react-query/src/QueryErrorResetBoundary.tsx index ba5fe3b2be5..a069d446e62 100644 --- a/packages/react-query/src/QueryErrorResetBoundary.tsx +++ b/packages/react-query/src/QueryErrorResetBoundary.tsx @@ -33,10 +33,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 +47,7 @@ export const QueryErrorResetBoundary = ({ const [value] = React.useState(() => createValue()) return ( - {typeof children === 'function' - ? (children as Function)(value) - : children} + {typeof children === 'function' ? children(value) : children} ) } From e6ed5ca0f235dfa09cbf2d3506d482a5b9e53c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Curley?= Date: Mon, 23 Sep 2024 17:44:10 +0100 Subject: [PATCH 2/2] fix: add extra functions --- packages/react-query/src/QueryErrorResetBoundary.tsx | 9 ++++++--- packages/react-query/src/index.ts | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/react-query/src/QueryErrorResetBoundary.tsx b/packages/react-query/src/QueryErrorResetBoundary.tsx index a069d446e62..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 { diff --git a/packages/react-query/src/index.ts b/packages/react-query/src/index.ts index 7d4724bd976..75475eb93ee 100644 --- a/packages/react-query/src/index.ts +++ b/packages/react-query/src/index.ts @@ -36,6 +36,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,