Skip to content

Conversation

bc-peng
Copy link
Contributor

@bc-peng bc-peng commented Sep 5, 2025

What/Why?

Convert class component HostedWidgetPaymentComponent into function component.

Replacing class components with function components eliminates the need for traditional lifecycle methods and enables full adoption of React 18 features like hooks and concurrent rendering.

This modernization aligns with React’s roadmap and ensures greater compatibility with future updates.

Rollout/Rollback

Revert.

Testing

CI.

Manual Testing

Mollie CC

test.mov

Stripe CC

Screen.Recording.2025-09-09.at.17.23.13.mov

@bc-peng bc-peng requested a review from a team as a code owner September 5, 2025 06:16
Copy link
Contributor

@vitalii-koshovyi vitalii-koshovyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Please add screenshot or screen recording with demo.

@@ -2,6 +2,7 @@
"extends": ["../../.eslintrc.json"],
"rules": {
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unnecessary-condition": "off"
"@typescript-eslint/no-unnecessary-condition": "off",
"react-hooks/exhaustive-deps": "off"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to ignore a rule when necessary than to ignore it for the whole package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vitalii-koshovyi Thanks for reviewing my PRs.

The react-hooks/exhaustive-deps rule is a bit special. We’ve already disabled it in several packages (e.g., core, braintree-integration) because, in our context, useEffect often can’t depend on all variables without causing unexpected re-renders.

I’m thinking it might make sense to open a PR to disable this rule project-wide, since it’s already off in major packages.

"react-hooks/exhaustive-deps": "off", // 18 errors

"react-hooks/exhaustive-deps": "off"

cc @animesh1987

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For packages we should have the rules in one place for better tracking, rather than in individual files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus what @bc-peng said, the shared payment methods have quite a bit of variance per method that cause different behaviours.

@bc-peng
Copy link
Contributor Author

bc-peng commented Sep 9, 2025

A summary of the changes today:

  • Moved three subcomponents out of <HostedWidgetPaymentComponent />.
  • Add useCallback to props of lower level components in order to avoid unwanted re-renders.

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

Successfully merging this pull request may close these issues.

3 participants