weareseeed / react-square-web-payments-sdk

Easily create PCI-compliant inputs to accept payments online with the Square Payments API. It supports the following payment methods: credit and debit cards, ACH bank transfers, Apple Pay, Google Pay, Gift Cards and Afterpay/Clearpay.
https://react-square-payments.weareseeed.com/
MIT License
33 stars 35 forks source link

fix: cashApp not destroyed on unmount #100

Closed testerez closed 4 months ago

testerez commented 4 months ago

Your checklist for this pull request

🚨Please review the guidelines for contributing to this repository.

Description

On our checkout page, we have a back button that will unmount the CashAppPay component. When we try to pay again, we get this error:

Initializing Cash App Pay failed CashAppPayError: already rendered. must destroy before rendering again

This PR is calling cashApp?.destroy(); on useEffect cleanup function so that it's properly destroyed on unmount and works as expected when re-mounting.