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. #516

Open
2 tasks done
mariana-berkii opened this issue Apr 23, 2024 · 2 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

Copy link
Contributor

github-actions bot commented Jun 8, 2024

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@github-actions github-actions bot added the Stale label Jun 8, 2024
@wsbrunson
Copy link
Member

wsbrunson commented Jun 10, 2024

We have moved this repository to our paypal-js monorepo: https://github.com/paypal/paypal-js

We will be archiving this repo at the end of the day which will turn off Issues activity. If this is still an issue for you, please re-open this issue here:

Transferring this issue here: https://github.com/paypal/paypal-js/issues

@wsbrunson wsbrunson transferred this issue from paypal/react-paypal-js Jun 10, 2024
@github-actions github-actions bot removed the Stale label Jun 11, 2024
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

2 participants