Skip to content

Commit

Permalink
Merge pull request #8832 from Expensify/justice_refactorActions-Enabl…
Browse files Browse the repository at this point in the history
…eStep.js

Re-fetch actions when we move from offline to online in EnableStep.js
  • Loading branch information
marcaaron authored May 18, 2022
2 parents d387f0e + 0991167 commit 9ab001c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/pages/ReimbursementAccount/EnableStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ import * as Illustrations from '../../components/Icon/Illustrations';
import * as BankAccounts from '../../libs/actions/BankAccounts';
import * as Link from '../../libs/actions/Link';
import * as User from '../../libs/actions/User';
import {withNetwork} from '../../components/OnyxProvider';
import networkPropTypes from '../../components/networkPropTypes';

const propTypes = {
/** Are we loading payment methods? */
isLoadingPaymentMethods: PropTypes.bool,

/** Information about the network */
network: networkPropTypes.isRequired,

/** List of bank accounts */
bankAccountList: PropTypes.objectOf(bankAccountPropTypes),

Expand All @@ -42,6 +47,18 @@ const defaultProps = {

class EnableStep extends React.Component {
componentDidMount() {
this.fetchData();
}

componentDidUpdate(prevProps) {
if (!prevProps.network.isOffline || this.props.network.isOffline) {
return;
}

this.fetchData();
}

fetchData() {
PaymentMethods.getPaymentMethods();
}

Expand Down Expand Up @@ -133,6 +150,7 @@ EnableStep.defaultProps = defaultProps;

export default compose(
withLocalize,
withNetwork(),
withOnyx({
isLoadingPaymentMethods: {
key: ONYXKEYS.IS_LOADING_PAYMENT_METHODS,
Expand Down

0 comments on commit 9ab001c

Please sign in to comment.