From 2ee4881fba9c13b9663db2838bb28fb99543d168 Mon Sep 17 00:00:00 2001 From: Albert Folch Date: Mon, 18 Mar 2024 17:21:19 +0100 Subject: [PATCH] refactor --- .../widgets/commit/CommitWidget.tsx | 4 +-- .../widgets/commit/CommitWidgetProviders.tsx | 25 ++++++++++++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/packages/react-kit/src/components/widgets/commit/CommitWidget.tsx b/packages/react-kit/src/components/widgets/commit/CommitWidget.tsx index e62b7019c..73882bac9 100644 --- a/packages/react-kit/src/components/widgets/commit/CommitWidget.tsx +++ b/packages/react-kit/src/components/widgets/commit/CommitWidget.tsx @@ -47,10 +47,10 @@ export function CommitWidget(props: CommitWidgetProps) { // @ts-ignore [props.lookAndFeel, props.modalMargin] ); - const provider = useProvider(); + return ( - + diff --git a/packages/react-kit/src/components/widgets/commit/CommitWidgetProviders.tsx b/packages/react-kit/src/components/widgets/commit/CommitWidgetProviders.tsx index 5908ec4e3..f1da36d84 100644 --- a/packages/react-kit/src/components/widgets/commit/CommitWidgetProviders.tsx +++ b/packages/react-kit/src/components/widgets/commit/CommitWidgetProviders.tsx @@ -25,8 +25,7 @@ import { useProvider } from "../../../hooks/connection/connection"; export type CommitWidgetProvidersProps = IpfsProviderProps & Omit & ConvertionRateProviderProps & - Omit & - Pick & { + Omit & { children: ReactNode; withReduxProvider: boolean; }; @@ -62,7 +61,6 @@ export const CommitWidgetReduxUpdaters = ({ export const CommitWidgetProviders: React.FC = ({ children, withReduxProvider, - provider, ...props }) => { const isWindowVisible = useIsWindowVisible(); @@ -82,15 +80,15 @@ export const CommitWidgetProviders: React.FC = ({ const WithUpdaters = useCallback( ({ children: updatersChildren }: { children: ReactNode }) => { return withReduxProvider ? ( - + {updatersChildren} - + ) : ( <>{updatersChildren} ); // eslint-disable-next-line react-hooks/exhaustive-deps }, - [withReduxProvider, isWindowVisible, provider] + [withReduxProvider, isWindowVisible] ); return ( @@ -120,3 +118,18 @@ export const CommitWidgetProviders: React.FC = ({ ); }; + +function UpdatersWrapper({ + children, + isWindowVisible +}: { + children: ReactNode; + isWindowVisible: boolean; +}) { + const provider = useProvider(); + return ( + + {children} + + ); +}