Skip to content

Commit

Permalink
Use a ref instead of a variable.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgolen committed Feb 5, 2024
1 parent df02d87 commit 77be411
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pages/iou/request/step/IOURequestStepConfirmation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import lodashGet from 'lodash/get';
import PropTypes from 'prop-types';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import React, {useCallback, useEffect, useMemo, useState, useRef} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import _ from 'underscore';
Expand Down Expand Up @@ -105,7 +105,7 @@ function IOURequestStepConfirmation({
[transaction.participants, personalDetails],
);
const isPolicyExpenseChat = useMemo(() => ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)), [report]);
let formHasBeenSubmitted = false;
const formHasBeenSubmitted = useRef(false);

useEffect(() => {
if (!transaction || !transaction.originalCurrency) {
Expand Down Expand Up @@ -230,11 +230,11 @@ function IOURequestStepConfirmation({
const trimmedComment = lodashGet(transaction, 'comment.comment', '').trim();

// Don't let the form be submitted multiple times while the navigator is waiting to take the user to a different page
if (formHasBeenSubmitted) {
if (formHasBeenSubmitted.current) {
return;
}

formHasBeenSubmitted = true;
formHasBeenSubmitted.current = true;

// If we have a receipt let's start the split bill by creating only the action, the transaction, and the group DM if needed
if (iouType === CONST.IOU.TYPE.SPLIT && receiptFile) {
Expand Down

0 comments on commit 77be411

Please sign in to comment.