Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

bc-peng
Copy link
Contributor

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

What/Why?

Convert class component CreditCardNumberInput 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.

@bc-peng bc-peng requested a review from a team as a code owner September 3, 2025 05:46
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
});
}, []);

Copy link
Contributor

Choose a reason for hiding this comment

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

Also do we need to add deps here, since this replacing componentDidUpdate and not componentDidmount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory, [] should not be set in order to run this whenever something changes.
And we only trigger updates when inputRef.current && inputRef.current.selectionEnd !== nextSelectionEndRef.current is met.

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 a screenshot.

animesh1987
animesh1987 previously approved these changes Sep 9, 2025
@bc-peng bc-peng requested a review from a team as a code owner September 11, 2025 05:18
refactor(checkout): CHECKOUT-9386 CreditCardNumberInput
@bc-peng bc-peng force-pushed the CreditCardNumberInput branch from 0004a6e to 327871f Compare September 11, 2025 05:20
@bc-peng bc-peng force-pushed the CreditCardNumberInput branch from 327871f to 2de5c47 Compare September 11, 2025 06:05
@bc-peng bc-peng requested a review from a team as a code owner September 11, 2025 06:30
@bc-peng bc-peng force-pushed the CreditCardNumberInput branch from 2d6eb82 to ca16b3b Compare September 11, 2025 06:45
@@ -260,9 +260,7 @@ const BigCommercePaymentsCreditCardsPaymentMethod: FunctionComponent<PaymentMeth
[getHostedFormOptions, initializePayment],
);

// Info: isHostedFormEnabled is an option in store config which responsible for switching BigCommercePayments Credit Card form
// rendering between Hosted Form and default BC fields (non-hosted)
return isHostedFormEnabled ? (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the branch when isHostedFormEnabled is false.
Confirmed internally this is no longer possible.

@bc-peng bc-peng changed the title refactor(checkout): CHECKOUT-9386 Convert CreditCardNumberInput [HOLD] refactor(checkout): CHECKOUT-9386 Convert CreditCardNumberInput Sep 11, 2025
import { LoadingOverlay } from '@bigcommerce/checkout/ui';

export interface CreditCardPaymentMethodProps {
cardFieldset?: ReactNode;
cardFieldset: ReactNode;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making cardFieldSet required, because every payment method that uses <CreditCardPaymentMethodComponent /> now must configure its own card validation field set.

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