diff --git a/src/pages/iou/IOUCurrencySelection.js b/src/pages/iou/IOUCurrencySelection.js index 09ad555d5c04..53b45dce1a6b 100644 --- a/src/pages/iou/IOUCurrencySelection.js +++ b/src/pages/iou/IOUCurrencySelection.js @@ -20,6 +20,8 @@ import KeyboardAvoidingView from '../../components/KeyboardAvoidingView'; import Button from '../../components/Button'; import FixedFooter from '../../components/FixedFooter'; import * as IOU from '../../libs/actions/IOU'; +import {withNetwork} from '../../components/OnyxProvider'; +import networkPropTypes from '../../components/networkPropTypes'; /** * IOU Currency selection for selecting currency @@ -51,7 +53,11 @@ const propTypes = { // ISO4217 Code for the currency ISO4217: PropTypes.string, })), + + /** Information about the network from Onyx */ + network: networkPropTypes.isRequired, ...withLocalizePropTypes, + }; const defaultProps = { @@ -84,7 +90,15 @@ class IOUCurrencySelection extends Component { } componentDidMount() { - PersonalDetails.getCurrencyList(); + this.fetchData(); + } + + componentDidUpdate(prevProps) { + if (!prevProps.network.isOffline || this.props.network.isOffline) { + return; + } + + this.fetchData(); } /** @@ -120,6 +134,10 @@ class IOUCurrencySelection extends Component { return currencyOptions; } + fetchData() { + PersonalDetails.getCurrencyList(); + } + /** * Function which toggles a currency in the list * @@ -244,4 +262,5 @@ export default compose( myPersonalDetails: {key: ONYXKEYS.MY_PERSONAL_DETAILS}, iou: {key: ONYXKEYS.IOU}, }), + withNetwork(), )(IOUCurrencySelection);