Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Failed to render <PayPalHostedFieldsProvider /> component. #431

Open
2 tasks done
mariana-berkii opened this issue Apr 23, 2024 · 0 comments
Open
2 tasks done

Comments

@mariana-berkii
Copy link

mariana-berkii commented Apr 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

🐞 Describe the Bug

When the Hosted Fields component rerenders due to state changes, an error appears:
Failed to render component. BraintreeError: Element already contains a Braintree iframe.
As I understand this happens because the PayPalHostedFieldsProvider component has been initiated and when rerender happens, the PayPalHostedFieldsProvider component doesn't check if the hosted fields instance exists, it just tries to render the card fields again, which throws an error.

😕 Current Behavior

On rerenderings Hosted Fields fail with the error:

react-paypal-js.js:1237 Uncaught Error: Failed to render <PayPalHostedFieldsProvider /> component. BraintreeError: Element already contains a Braintree iframe.
    at react-paypal-js.js:1237:15
    at basicStateReducer (react-dom.development.js:16540:41)
    at updateReducer (react-dom.development.js:16664:22)
    at updateState (react-dom.development.js:17004:10)
    at Object.useState (react-dom.development.js:17915:16)
    at useState (react.development.js:1622:21)
    at PayPalHostedFieldsProvider (react-paypal-js.js:1188:20)
    at renderWithHooks (react-dom.development.js:16305:18)
    at updateFunctionComponent (react-dom.development.js:19588:20)
    at beginWork (react-dom.development.js:21601:16)

🤔 Expected Behavior

When the checkout page rerenders due to state changes (e.g. changes to basket), it would be good if in such cases the PayPal Hosted Fields component would not try to render Hosted Fields once again, but use the existing instance.

🔬 Minimal Reproduction

No response

🌍 Environment

| Software         |            Version(s)           |
| ---------------- | ------------------------------- |
| react-paypal-js  |              8.1.3              |
| Browser          |   Google Chrome 124.0.6367.60   |
| Operating System |   Windows 10 Enterprise 64-bit  |

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

➕ Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant