Skip to content

Commit 4775a21

Browse files
Merge pull request stripe#5 from stripe/fix-ssr
Fix ssr
2 parents 1268173 + c18266c commit 4775a21

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stripe/stripe-js",
3-
"version": "1.0.0-beta.1",
3+
"version": "1.0.0-beta.2",
44
"description": "Stripe.js loading utility",
55
"main": "dist/stripe.js",
66
"module": "dist/stripe.esm.js",

src/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ const stripePromise = Promise.resolve().then(() => {
5151
let hasCalledLoadStripe = false;
5252
export const loadStripe = (...args) => {
5353
hasCalledLoadStripe = true;
54-
return stripePromise.then((Stripe) => Stripe(...args));
54+
return stripePromise.then((maybeStripe) =>
55+
maybeStripe ? maybeStripe(...args) : null
56+
);
5557
};
5658

5759
const STRIPE_NOT_LOADED_ERROR_TEXT = `Stripe.js has not yet loaded. Instead of calling \`Stripe\` directly, try using the \`loadStripe\` utility from this package.
@@ -74,7 +76,7 @@ const hasUserIncludedScript = () =>
7476
document.querySelector(`script[src="${V3_URL}"]`) && !hasInjectedScript;
7577

7678
export const Stripe = (...args) => {
77-
if (window.Stripe) {
79+
if (window && window.Stripe) {
7880
return window.Stripe(...args);
7981
}
8082

0 commit comments

Comments
 (0)