From 185c9877f1494052b2115a5c97e093aab1083e72 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Sat, 15 Jun 2019 11:51:12 +0100 Subject: [PATCH 01/13] refactor: migrate CreateExpenseForm --- src/apps/expenses/components/CreateExpenseForm.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/apps/expenses/components/CreateExpenseForm.js b/src/apps/expenses/components/CreateExpenseForm.js index be8a61ac129..8bd261c33e3 100644 --- a/src/apps/expenses/components/CreateExpenseForm.js +++ b/src/apps/expenses/components/CreateExpenseForm.js @@ -87,9 +87,9 @@ class CreateExpenseForm extends React.Component { }; } - UNSAFE_componentWillReceiveProps(newProps) { - if (!this.props.LoggedInUser && newProps.LoggedInUser && !this.state.expense.paypalEmail) { - this.handleChange('paypalEmail', newProps.LoggedInUser.paypalEmail); + componentDidUpdate(prevProps) { + if (!prevProps.LoggedInUser && this.props.LoggedInUser && !this.state.expense.paypalEmail) { + this.handleChange('paypalEmail', this.props.LoggedInUser.paypalEmail); } } From d3d21ced6b0eb3be8e9ccb4fe6cc1e376bd89b3b Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Sat, 15 Jun 2019 11:53:30 +0100 Subject: [PATCH 02/13] refactor: migrate TransactionsWithData --- src/apps/expenses/components/TransactionsWithData.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/expenses/components/TransactionsWithData.js b/src/apps/expenses/components/TransactionsWithData.js index 5d8c0fef9fb..2181a6249af 100644 --- a/src/apps/expenses/components/TransactionsWithData.js +++ b/src/apps/expenses/components/TransactionsWithData.js @@ -24,8 +24,8 @@ class TransactionsWithData extends React.Component { super(props); } - UNSAFE_componentWillReceiveProps(nextProps) { - if (!this.props.LoggedInUser && nextProps.LoggedInUser) { + componentDidUpdate(prevProps) { + if (!prevProps.LoggedInUser && this.props.LoggedInUser) { return this.props.data.refetch(); } } From 23a02c6734eb956ccd40dc00376568d5ea826ffa Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Sat, 15 Jun 2019 11:57:25 +0100 Subject: [PATCH 03/13] refactor: migrate CreateCollectiveForm --- src/components/CreateCollectiveForm.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/CreateCollectiveForm.js b/src/components/CreateCollectiveForm.js index 6927117a98e..e789274c991 100644 --- a/src/components/CreateCollectiveForm.js +++ b/src/components/CreateCollectiveForm.js @@ -124,14 +124,14 @@ class CreateCollectiveForm extends React.Component { } } - UNSAFE_componentWillReceiveProps(nextProps) { + componentDidUpdate(prevProps) { if ( - nextProps.collective && - (!this.props.collective || get(nextProps, 'collective.name') != get(this.props, 'collective.name')) + this.props.collective && + (!prevProps.collective || get(this.props, 'collective.name') !== get(prevProps, 'collective.name')) ) { this.setState({ - collective: nextProps.collective, - tiers: nextProps.collective.tiers, + collective: this.props.collective, + tiers: this.props.collective.tiers, }); } } From f86d797ed48a03944bcab6b1cdb0b764dd81e396 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Sat, 15 Jun 2019 11:58:47 +0100 Subject: [PATCH 04/13] refactor: migrate EditEventForm --- src/components/EditEventForm.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/EditEventForm.js b/src/components/EditEventForm.js index e70c307f854..f3b6a39a454 100644 --- a/src/components/EditEventForm.js +++ b/src/components/EditEventForm.js @@ -52,9 +52,9 @@ class EditEventForm extends React.Component { }); } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.event && (!this.props.event || nextProps.event.name != this.props.event.name)) { - this.setState({ event: nextProps.event, tiers: nextProps.event.tiers }); + componentDidUpdate(prevProps) { + if (this.props.event && (!prevProps.event || this.props.event.name !== prevProps.event.name)) { + this.setState({ event: this.props.event, tiers: this.props.event.tiers }); } } From 9462ac901e086eea63af8b8b477701088be4e55a Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Sat, 15 Jun 2019 12:00:43 +0100 Subject: [PATCH 05/13] refactor: migrate InputField --- src/components/InputField.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/InputField.js b/src/components/InputField.js index fe780f58295..f1377572c92 100644 --- a/src/components/InputField.js +++ b/src/components/InputField.js @@ -110,9 +110,9 @@ class InputField extends React.Component { this.handleChange = this.handleChange.bind(this); } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.value != this.props.value) { - this.setState({ value: nextProps.value }); + componentDidUpdate(prevProps) { + if (this.props.value !== prevProps.value) { + this.setState({ value: this.props.value }); } } From f6ce34d9b166a2198f0729f4ea0a84c1dafb2317 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 17 Jun 2019 19:52:11 +0100 Subject: [PATCH 06/13] refactor: migrate InputTypeCreditCard --- src/components/InputTypeCreditCard.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/InputTypeCreditCard.js b/src/components/InputTypeCreditCard.js index 3c3a6ec5071..561016d5b3b 100644 --- a/src/components/InputTypeCreditCard.js +++ b/src/components/InputTypeCreditCard.js @@ -55,10 +55,10 @@ class InputTypeCreditCard extends React.Component { } } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.options && nextProps.options.length > 0) { + componentDidUpdate() { + if (this.props.options && this.props.options.length > 0) { if (typeof this.state.uuid !== 'string') { - this.handleChange('uuid', nextProps.options[0].uuid); + this.handleChange('uuid', this.props.options[0].uuid); } } } From 0b0ccf99dc5fe2fbbf1a3083107540320233e6e9 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 17 Jun 2019 20:30:44 +0100 Subject: [PATCH 07/13] fix bug in createExpenseForm --- src/apps/expenses/components/CreateExpenseForm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apps/expenses/components/CreateExpenseForm.js b/src/apps/expenses/components/CreateExpenseForm.js index 8bd261c33e3..25a2f522cb3 100644 --- a/src/apps/expenses/components/CreateExpenseForm.js +++ b/src/apps/expenses/components/CreateExpenseForm.js @@ -80,7 +80,7 @@ class CreateExpenseForm extends React.Component { expense: { category: Object.keys(this.categoriesOptions[0])[0], payoutMethod: 'paypal', - paypalEmail: (props.LoggedInUser && props.LoggedInUser.paypalEmail) || null, + paypalEmail: (props.LoggedInUser && props.LoggedInUser.paypalEmail) || undefined, }, isExpenseValid: false, loading: false, @@ -463,7 +463,7 @@ class CreateExpenseForm extends React.Component { type="email" name="paypalEmail" key={`paypalEmail-${get(LoggedInUser, 'id')}`} - defaultValue={this.state.expense.paypalEmail} + value={this.state.expense.paypalEmail} onChange={paypalEmail => this.handleChange('paypalEmail', paypalEmail)} /> From cad3e1b6920847eba25420e0b562d10b610fe3af Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 17 Jun 2019 20:36:58 +0100 Subject: [PATCH 08/13] refactor: migrate InputTypeLocation --- src/components/InputTypeLocation.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/InputTypeLocation.js b/src/components/InputTypeLocation.js index 50dc96088b8..d93b66c44d3 100644 --- a/src/components/InputTypeLocation.js +++ b/src/components/InputTypeLocation.js @@ -19,9 +19,9 @@ class InputTypeLocation extends React.Component { this.state = { value: props.value || {} }; } - UNSAFE_componentWillReceiveProps(nextProps) { - if (nextProps.value != this.props.value) { - this.setState({ value: nextProps.value }); + componentDidUpdate(prevProps) { + if (this.props.value !== prevProps.value) { + this.setState({ value: this.props.value }); } } From c58192d4d7bce5e0de6d469ab0447b8b307d38d5 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 17 Jun 2019 20:39:51 +0100 Subject: [PATCH 09/13] refactor: migrate MatchingFundWithData --- src/components/MatchingFundWithData.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/MatchingFundWithData.js b/src/components/MatchingFundWithData.js index a77202b1503..34b832be7d4 100644 --- a/src/components/MatchingFundWithData.js +++ b/src/components/MatchingFundWithData.js @@ -25,14 +25,13 @@ class MatchingFundWithData extends React.Component { this.props.onChange(this.uuid); } - // Whenever this.props.order.totalAmount changes, we update the status - async UNSAFE_componentWillReceiveProps(newProps) { + async componentDidUpdate(prevProps) { const { data: { loading, MatchingFund }, collective, order, uuid, - } = newProps; + } = this.props; if (loading) return; // if the matching fund id doesn't return any matching fund, we notify the OrderForm @@ -42,7 +41,7 @@ class MatchingFundWithData extends React.Component { return; } - if (order.totalAmount === this.props.order.totalAmount) return; + if (order.totalAmount === prevProps.order.totalAmount) return; const currency = get(MatchingFund, 'currency'); if (currency && currency !== collective.currency) { this.fxrate = await getFxRate(collective.currency, currency); From f03766155c8fd89a96a8361df7f1a08f53a26837 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 17 Jun 2019 20:54:30 +0100 Subject: [PATCH 10/13] refactor: migrate PaymentMethodChooser --- src/components/PaymentMethodChooser.js | 34 ++++++++++++++------------ 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/components/PaymentMethodChooser.js b/src/components/PaymentMethodChooser.js index bd3ce2b3711..5f535082f4d 100644 --- a/src/components/PaymentMethodChooser.js +++ b/src/components/PaymentMethodChooser.js @@ -67,29 +67,31 @@ class PaymentMethodChooser extends React.Component { }); } - UNSAFE_componentWillReceiveProps(newProps) { + componentDidUpdate(prevProps) { // TODO: Remove these hacky fixes // Most likely means need to rework the logic split between this and SubscriptionCard component - const { paymentMethodInUse, paymentMethodsList, editMode } = newProps; + const { paymentMethodInUse, paymentMethodsList, editMode } = this.props; - if (!paymentMethodInUse.name) { - // set state to modified - this.setState({ modified: true }); - // If there was an existing card, select that - if (paymentMethodsList.length > 0) { - this.handleChange({ uuid: paymentMethodsList[0].uuid }); + if (!prevProps.paymentMethodsList && paymentMethodsList) { + if (!paymentMethodInUse.name) { + // set state to modified + this.setState({ modified: true }); + // If there was an existing card, select that + if (paymentMethodsList.length > 0) { + this.handleChange({ uuid: paymentMethodsList[0].uuid }); + } } - } - // hack to revert back to cc selector - if (!this.props.editMode && editMode) { - this.setState({ showNewCreditCardForm: false }); - } + // hack to revert back to cc selector + if (!prevProps.editMode && editMode) { + this.setState({ showNewCreditCardForm: false }); + } - // handles the case where there are no existing credit cards - if (paymentMethodsList.length === 0 && editMode) { - this.setState({ showNewCreditCardForm: true }); + // handles the case where there are no existing credit cards + if (paymentMethodsList.length === 0 && editMode) { + this.setState({ showNewCreditCardForm: true }); + } } } From ddca815b3feaf1e2cee0696c7f07559fb73f0874 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 17 Jun 2019 20:59:13 +0100 Subject: [PATCH 11/13] refactor: migrate Subscriptions --- src/components/Subscriptions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Subscriptions.js b/src/components/Subscriptions.js index 79331df8851..8319b6cc0fc 100644 --- a/src/components/Subscriptions.js +++ b/src/components/Subscriptions.js @@ -35,8 +35,8 @@ class Subscriptions extends React.Component { }); } - UNSAFE_componentWillReceiveProps(nextProps) { - if (!this.props.LoggedInUser && nextProps.LoggedInUser) { + componentDidUpdate(prevProps) { + if (!prevProps.LoggedInUser && this.props.LoggedInUser) { return this.props.refetch(); } } From 44e5d7fef0273172d5396b269151954fd2827c59 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 17 Jun 2019 21:01:20 +0100 Subject: [PATCH 12/13] refactor: migrate UpdatesWithData --- src/components/UpdatesWithData.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/UpdatesWithData.js b/src/components/UpdatesWithData.js index 309c208c455..03c9a8375cd 100644 --- a/src/components/UpdatesWithData.js +++ b/src/components/UpdatesWithData.js @@ -27,10 +27,10 @@ class UpdatesWithData extends React.Component { }; } - UNSAFE_componentWillReceiveProps(newProps) { + componentDidUpdate(prevProps) { const { data, collective } = this.props; - const { LoggedInUser } = newProps; - if (LoggedInUser && LoggedInUser.canEditCollective(collective)) { + const { LoggedInUser } = this.props; + if (!prevProps.LoggedInUser && LoggedInUser && LoggedInUser.canEditCollective(collective)) { // We refetch the data to get the updates that are not published yet data.refetch({ options: { fetchPolicy: 'network-only' } }); } From 2a95482b6b9f97fc9cca5cb3195aed2a88439bd6 Mon Sep 17 00:00:00 2001 From: Elijah Oyekunle Date: Mon, 17 Jun 2019 21:01:59 +0100 Subject: [PATCH 13/13] refactor: migrate banner-iframe --- src/pages/banner-iframe.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/pages/banner-iframe.js b/src/pages/banner-iframe.js index 214bfeffaae..b7f21c19c95 100644 --- a/src/pages/banner-iframe.js +++ b/src/pages/banner-iframe.js @@ -32,10 +32,6 @@ class BannerIframe extends React.Component { this.onChange(); } - UNSAFE_componentWillReceiveProps() { - this.onChange(); - } - componentDidUpdate() { this.onChange(); }