-
Notifications
You must be signed in to change notification settings - Fork 398
refactor(checkout): CHECKOUT-9386 Convert CreditCardPaymentMethodComponent #2530
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
Conversation
|
||
private getCreditCardPaymentMethodDerivedProps(): CreditCardPaymentMethodDerivedProps { | ||
const { checkoutService, checkoutState, isUsingMultiShipping = false, method } = this.props; | ||
useEffect(() => { |
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.
I’ve used three separate useEffect()
hooks here, each handling a different existing concern componentDidMount, componentDidUpdate, and componentWillUnmount.
Merging them into a single useEffect()
would blur the distinction between dependencies and lifecycle behaviors.
However, I’m happy to merge them if we think that’s prefered. ⏩️
} | ||
}; | ||
|
||
void deInit(); |
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.
I have created init()
, reInit()
and deInit()
inside hooks.
Using explicit names makes their purpose clearer.
We may need to align on a consistent naming for these methods. ⏩️
dc3c6c8
to
1d46946
Compare
1d46946
to
ebb9996
Compare
}, [method, selectedInstrumentId, isAddingNewCard]); | ||
|
||
useEffect(() => { | ||
return () => { |
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.
Can this be a return from the effect that initialises the component?
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.
Sure, I have combined both hooks into one useEffect()
.
checkout-js deployed to Integration US |
checkout-js deployed to Staging US |
checkout-js deployed to Production US |
What/Why?
Convert class component
CreditCardPaymentMethodComponent
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.