Skip to content

Commit

Permalink
use useUpdateWithSetter & remove visible
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiying-stripe committed Dec 7, 2023
1 parent 9e00a64 commit 203203e
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/Components.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from 'react';
import {useCreateComponent} from './useCreateComponent';

Check failure on line 1 in src/Components.tsx

View workflow job for this annotation

GitHub Actions / test

Argument of type '"payments"' is not assignable to parameter of type '"account-onboarding"'.

Check failure on line 1 in src/Components.tsx

View workflow job for this annotation

GitHub Actions / test

Argument of type '"payouts"' is not assignable to parameter of type '"account-onboarding"'.

Check failure on line 1 in src/Components.tsx

View workflow job for this annotation

GitHub Actions / test

Argument of type '"payment-details"' is not assignable to parameter of type '"account-onboarding"'.

Check failure on line 1 in src/Components.tsx

View workflow job for this annotation

GitHub Actions / test

Property 'setPayment' does not exist on type 'HTMLElement & { setFullTermsOfServiceUrl: (termOfServiceUrl: string | undefined) => void; setRecipientTermsOfServiceUrl: (recipientTermsOfServiceUrl: string | undefined) => void; setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined) => void; setSkipTermsOfServiceCollection: (skipTermsOfServiceCollection: boole...'.

Check failure on line 1 in src/Components.tsx

View workflow job for this annotation

GitHub Actions / test

Property 'setOnClose' does not exist on type 'HTMLElement & { setFullTermsOfServiceUrl: (termOfServiceUrl: string | undefined) => void; setRecipientTermsOfServiceUrl: (recipientTermsOfServiceUrl: string | undefined) => void; setPrivacyPolicyUrl: (privacyPolicyUrl: string | undefined) => void; setSkipTermsOfServiceCollection: (skipTermsOfServiceCollection: boole...'. Did you mean 'onclose'?
import {useAttachAttribute} from './utils/useAttachAttribute';
import {useUpdateWithSetter} from './utils/useUpdateWithSetter';

export const ConnectPayments = (): JSX.Element => {
Expand All @@ -15,26 +13,23 @@ export const ConnectPayouts = (): JSX.Element => {

export const ConnectPaymentDetails = ({
payment,
onClose,
visible = undefined,
onClose
}: {
/**
* @param payment the ID of `payment`, `charge`, or `paymentIntent` to be displayed.
*/
payment: string;
onClose: () => void;
visible?: boolean | undefined;
}): JSX.Element | null => {
const {wrapper, component: paymentDetails} =
useCreateComponent('payment-details');

useAttachAttribute(paymentDetails, 'visible', visible);
React.useEffect(() => {
if (!paymentDetails) return;
paymentDetails.setPayment(payment);
paymentDetails.setOnClose(onClose);
}, [paymentDetails, payment, onClose]);

useUpdateWithSetter(paymentDetails, payment, (comp, val) =>
comp.setPayment(val)
);
useUpdateWithSetter(paymentDetails, onClose, (comp, val) =>
comp.setOnClose(val)
);
return wrapper;
};

Expand Down

0 comments on commit 203203e

Please sign in to comment.