From 432fc4d6e6ade11a586538b78093a911c125ea17 Mon Sep 17 00:00:00 2001 From: Julia Chaves Date: Fri, 26 Jul 2024 15:42:54 -0700 Subject: [PATCH] add values in callback --- package.json | 2 +- src/Components.tsx | 12 ++++++------ src/utils/useUpdateWithSetter.ts | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index fc3586f..ad94426 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "zx": "^4.2.0" }, "peerDependencies": { - "@stripe/connect-js": ">=3.3.12-beta-1", + "@stripe/connect-js": ">=3.3.13-beta-1", "react": ">=16.8.0", "react-dom": ">=16.8.0" } diff --git a/src/Components.tsx b/src/Components.tsx index 366ee7c..f23d7a3 100644 --- a/src/Components.tsx +++ b/src/Components.tsx @@ -1,7 +1,7 @@ import {useCreateComponent} from './useCreateComponent'; import {useUpdateWithSetter} from './utils/useUpdateWithSetter'; import {CollectionOptions, FetchEphemeralKeyFunction} from './types'; -import {NotificationCount} from '@stripe/connect-js'; +import {NotificationCount, InstallState} from '@stripe/connect-js'; export const ConnectAppInstall = ({ app, @@ -9,19 +9,19 @@ export const ConnectAppInstall = ({ onAppInstallStateChange, }: { app: string; - onAppInstallStateFetch: () => void; - onAppInstallStateChange: () => void; + onAppInstallStateFetch?: (({appId, state}: InstallState) => void) | undefined; + onAppInstallStateChange?: + | (({appId, state}: InstallState) => void) + | undefined; }): JSX.Element | null => { const {wrapper, component: appInstall} = useCreateComponent('app-install'); useUpdateWithSetter(appInstall, app, (comp, val) => comp.setApp(val)); - useUpdateWithSetter(appInstall, onAppInstallStateFetch, (comp, val) => comp.setOnAppInstallStateFetched(val) ); useUpdateWithSetter(appInstall, onAppInstallStateChange, (comp, val) => comp.setOnAppInstallStateChanged(val) ); - return wrapper; }; @@ -30,7 +30,7 @@ export const ConnectAppViewport = ({ appData, }: { app: string; - appData: Record; + appData?: Record; }): JSX.Element | null => { const {wrapper, component: appViewport} = useCreateComponent('app-viewport'); useUpdateWithSetter(appViewport, app, (comp, val) => comp.setApp(val)); diff --git a/src/utils/useUpdateWithSetter.ts b/src/utils/useUpdateWithSetter.ts index 062559c..8d9d964 100644 --- a/src/utils/useUpdateWithSetter.ts +++ b/src/utils/useUpdateWithSetter.ts @@ -1,6 +1,6 @@ import React from 'react'; import {CollectionOptions, FetchEphemeralKeyFunction} from '../types'; -import {NotificationCount} from '@stripe/connect-js'; +import {InstallState, NotificationCount} from '@stripe/connect-js'; export const useUpdateWithSetter = < T extends HTMLElement, @@ -12,6 +12,7 @@ export const useUpdateWithSetter = < | FetchEphemeralKeyFunction | CollectionOptions | ((notificationCount: NotificationCount) => void) + | ((installState: InstallState) => void) | undefined >( component: T | null,