Skip to content

Commit

Permalink
add values in callback
Browse files Browse the repository at this point in the history
  • Loading branch information
chaves-stripe committed Jul 26, 2024
1 parent f4df27d commit 432fc4d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
12 changes: 6 additions & 6 deletions src/Components.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
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,
onAppInstallStateFetch,
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;
};

Expand All @@ -30,7 +30,7 @@ export const ConnectAppViewport = ({
appData,
}: {
app: string;
appData: Record<string, string>;
appData?: Record<string, string>;
}): JSX.Element | null => {
const {wrapper, component: appViewport} = useCreateComponent('app-viewport');
useUpdateWithSetter(appViewport, app, (comp, val) => comp.setApp(val));
Expand Down
3 changes: 2 additions & 1 deletion src/utils/useUpdateWithSetter.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -12,6 +12,7 @@ export const useUpdateWithSetter = <
| FetchEphemeralKeyFunction
| CollectionOptions
| ((notificationCount: NotificationCount) => void)
| ((installState: InstallState) => void)
| undefined
>(
component: T | null,
Expand Down

0 comments on commit 432fc4d

Please sign in to comment.