Skip to content
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

Merged
merged 13 commits into from
Jun 19, 2019
Merged

Conversation

eloyekunle
Copy link
Contributor

@eloyekunle eloyekunle commented Jun 15, 2019

  • ./src/apps/expenses/components/CreateExpenseForm.js
  • ./src/apps/expenses/components/TransactionsWithData.js
  • ./src/components/CreateCollectiveForm.js
  • ./src/components/EditEventForm.js
  • ./src/components/EditCollectiveForm.js
  • ./src/components/InputField.js
  • ./src/components/InputTypeCreditCard.js
  • ./src/components/InputTypeLocation.js
  • ./src/components/MatchingFundWithData.js
  • ./src/components/PaymentMethodChooser.js
  • ./src/components/Subscriptions.js
  • ./src/components/UpdatesWithData.js
  • ./src/pages/banner-iframe.js

Fixes opencollective/opencollective#1438

@vercel
Copy link

vercel bot commented Jun 15, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

@eloyekunle eloyekunle force-pushed the migrate/unsafeWillReceiveProps branch from 6cb908e to 185c987 Compare June 15, 2019 10:51
@vercel vercel bot temporarily deployed to staging June 15, 2019 10:51 Inactive
@vercel vercel bot temporarily deployed to staging June 15, 2019 10:53 Inactive
@vercel vercel bot temporarily deployed to staging June 15, 2019 10:57 Inactive
@vercel vercel bot temporarily deployed to staging June 15, 2019 10:59 Inactive
@vercel vercel bot temporarily deployed to staging June 17, 2019 19:37 Inactive
@vercel vercel bot temporarily deployed to staging June 17, 2019 19:54 Inactive
@vercel vercel bot temporarily deployed to staging June 17, 2019 19:59 Inactive
@vercel vercel bot temporarily deployed to staging June 17, 2019 20:01 Inactive
@eloyekunle eloyekunle changed the title WIP: Migrate UNSAFE_componentWillReceiveProps Migrate UNSAFE_componentWillReceiveProps Jun 17, 2019
@eloyekunle eloyekunle requested review from znarf and Betree June 17, 2019 20:10
@@ -463,7 +463,7 @@ class CreateExpenseForm extends React.Component {
type="email"
name="paypalEmail"
key={`paypalEmail-${get(LoggedInUser, 'id')}`}
defaultValue={this.state.expense.paypalEmail}
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

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) {
Copy link
Member

Choose a reason for hiding this comment

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

Why introducing this test?

Copy link
Contributor Author

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.

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.

Migrate all UNSAFE_componentWillReceiveProps
3 participants