Skip to content

Commit 4414846

Browse files
committed
upgrade to fix guest payment not loading
1 parent 6122181 commit 4414846

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react-paypal-js/src/v6/components/PayPalGuestPaymentButton.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ describe("PayPalGuestPaymentButton", () => {
8383
container.querySelector("paypal-basic-card-button"),
8484
).not.toBeInTheDocument();
8585
expect(container.querySelector("div")).toBeInTheDocument();
86-
// Container should NOT be present when not hydrated to avoid web component errors
86+
// Container should still be present even when not hydrated
8787
expect(
8888
container.querySelector("paypal-basic-card-container"),
89-
).not.toBeInTheDocument();
89+
).toBeInTheDocument();
9090
});
9191

9292
it("should call handleClick when button is clicked", () => {

packages/react-paypal-js/src/v6/components/PayPalGuestPaymentButton.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,17 @@ export const PayPalGuestPaymentButton = ({
3939
}
4040
}, [error]);
4141

42-
if (!isHydrated) {
43-
return <div />;
44-
}
45-
46-
return (
47-
<paypal-basic-card-container>
48-
<paypal-basic-card-button
49-
ref={buttonRef}
50-
onClick={handleClick}
51-
disabled={
52-
disabled || isPending || error !== null ? true : undefined
53-
}
54-
></paypal-basic-card-button>
55-
</paypal-basic-card-container>
42+
const button = isHydrated ? (
43+
<paypal-basic-card-button
44+
ref={buttonRef}
45+
onClick={handleClick}
46+
disabled={
47+
disabled || isPending || error !== null ? true : undefined
48+
}
49+
></paypal-basic-card-button>
50+
) : (
51+
<div />
5652
);
53+
54+
return <paypal-basic-card-container>{button}</paypal-basic-card-container>;
5755
};

0 commit comments

Comments
 (0)