-
-
Notifications
You must be signed in to change notification settings - Fork 408
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
Migrate UNSAFE_componentWillReceiveProps #1957
Conversation
This pull request is automatically deployed with Now. |
6cb908e
to
185c987
Compare
@@ -463,7 +463,7 @@ class CreateExpenseForm extends React.Component { | |||
type="email" | |||
name="paypalEmail" | |||
key={`paypalEmail-${get(LoggedInUser, 'id')}`} | |||
defaultValue={this.state.expense.paypalEmail} |
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.
Why this change?
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.
Initially, paypalEmail
is null
before the prop updates. defaultValue
binds to the initial value during the first render so it doesn't change if the user is actually logged in and has a default email.
This change fixes that.
// If there was an existing card, select that | ||
if (paymentMethodsList.length > 0) { | ||
this.handleChange({ uuid: paymentMethodsList[0].uuid }); | ||
if (!prevProps.paymentMethodsList && paymentMethodsList) { |
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.
Why introducing this test?
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.
To avoid infinite loops, since we're setting state in componentDidUpdate
. This ensures that the state will only be updated for this condition.
Fixes opencollective/opencollective#1438