-
Notifications
You must be signed in to change notification settings - Fork 218
Convert PaymentMethodErrorBoundary to class component #11746
Conversation
- Error boundary cannot be written as a function component, it should be a class component. - Convert PaymentMethodErrorBoundary from function component to class component.
The release ZIP for this PR is accessible via:
Script Dependencies ReportThere is no changed script dependency between this branch and trunk. This comment was automatically generated by the TypeScript Errors Report
assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-card.tsx
|
Size Change: +992 B (0%) Total Size: 1.53 MB
ℹ️ View Unchanged
|
This PR has been marked as If deemed still relevant, the pr can be kept active by ensuring it's up to date with the main branch and removing the stale label. |
// De-register the express payment method if has an error. | ||
if ( this.expressPaymentMethodId !== undefined ) { | ||
__experimentalDeRegisterExpressPaymentMethod( | ||
this.expressPaymentMethodId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such calls shouldn't be done in the render()
method, but in effects, i.e., the lifecycle methods like componentDidMount
and componentDidUpdate
.
Also, is it a good idea to unregister the method? Maybe the PaymentMethodErrorBoundary
should do just one job, reporting the error, and nothing else.
Thank you for the initial review, @jsnajdr. As we discussed, I will be dividing the solution into multiple PRs. The first PR will focus only on converting the function component to a class component. You can access this PR at #12088. I will be closing this PR for now and opening new PRs for each solution. I appreciate all your guidance and support. Thank you again for proposing breaking the solution to multiple PRs. |
WIP
What
Fixes woocommerce/woocommerce#42256
Why
Testing Instructions
Please consider any edge cases this change may have, and also other areas of the product this may impact.
Screenshots or screencast
WooCommerce Visibility
Required:
Checklist
Required:
[type]
label or a[skip-changelog]
label.Conditional:
[skip-changelog]
label is not present).Changelog