Immutable solution version
Error: Unable to render [PayPalButtons] because window.paypal.Buttons is undefined. To fix the issue, add...
Complete solution
If PayPalButtons fails with 'window.paypal.Buttons is undefined', do what the error says: pass components: 'buttons' in the parent PayPalScriptProvider options, and make sure PayPalButtons is rendered inside that provider. If it still fails intermittently, one user fixed it by adding dataNamespace: 'paypal_sdk' to the script options to avoid namespace conflicts, and another found an element with id 'paypal' was shadowing window.paypal, so check for ID collisions too.
What was reported: Issue paypal/paypal-js#572 (closed, 11 comments): ### react-paypal-js [paypal-js, react-paypal-js, direct script integration] ### 🐞 I am trying to integrate this. I am following the documentation. Sometimes my paypal button gets loaded but sometimes it doesn't in the component. How can I fix this? Uncaught runtime errors: × ERROR Unable to render [PayPalButtons] because window.paypal.Buttons is undefined. To fix the issue, add 'buttons' to the list of components passed to the parent PayPalScriptProvider: the PayPalScriptProvider element (options={{ components: 'buttons'}})`. Error: Unable to render [PayPalButtons] because window.paypal.
What works: If PayPalButtons fails with 'window.paypal.Buttons is undefined', do what the error says: pass components: 'buttons' in the parent PayPalScriptProvider options, and make sure PayPalButtons is rendered inside that provider. If it still fails intermittently, one user fixed it by adding dataNamespace: 'paypal_sdk' to the script options to avoid namespace conflicts, and another found an element with id 'paypal' was shadowing window.paypal, so check for ID collisions too.
Evidence
In the GitHub issue, the reporter asked: Error: Unable to render [PayPalButtons] because window.paypal.Buttons is undefined. To fix the issue, add.... The working answer that came out of the thread: If PayPalButtons fails with 'window.paypal.Buttons is undefined', do what the error says: pass components: 'buttons' in the parent PayPalScriptProvider options, and make sure PayPalButtons is rendered inside that provider. If it still fails intermittently, one user fixed it by adding dataNamespace: 'paypal_sdk' to the script options to avoid namespace conflicts, and another found an element with id 'paypal' was shadowing window.paypal, so check for ID collisions too. Source: https://github.com/paypal/paypal-js/issues/572
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_UfaLTWl2BszcF223k9wumQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Error: Unable to render [PayPalButtons] because window.paypal.Buttons is undefined. To fix the issue, add... <span>— Vectle</span></a>