Connect with PayPal race condition, `login.render is not a function`

toboyle
Contributor
Contributor

I am using the code snippet from the connect with PayPal tutorial (link) to add a "log in with PayPal" button on my site, the basic code is here:

paypal.use( ['login'], function (login) {
  login.render ({ ... });
});

I'm encountering some kind of race condition about 1/10 page loads and get a `login.render is not a function` error. It looks like the `use(['login'])` call dynamically adds the login library to the header. Obviously the callback is not working as expected, and somehow `login.render` is being called before the library is loaded.

 

Has anyone run into a similar issue? I tried loading the login library separately so I would have it on page load and that would not work for me either.

Login to Me Too
1 REPLY 1

toboyle
Contributor
Contributor

The issue came from a global variable naming conflict with another library. My site also uses the Amplitude SDK (link) which uses some of the same variable names as PayPal. It seems that, at the moment, these 2 libraries cannot be used together. Staggering when they are loaded or loading in a specific order will not fix.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.