Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/pages/iou/SplitExpensePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView
import Button from '@components/Button';
import ConfirmModal from '@components/ConfirmModal';
import FormHelpMessage from '@components/FormHelpMessage';
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MenuItem from '@components/MenuItem';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
Expand Down Expand Up @@ -54,6 +55,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
import SplitList from './SplitList';

type SplitExpensePageProps = PlatformStackScreenProps<SplitExpenseParamList, typeof SCREENS.MONEY_REQUEST.SPLIT_EXPENSE>;
Expand All @@ -72,7 +74,8 @@ function SplitExpensePage({route}: SplitExpensePageProps) {
const searchContext = useSearchContext();

const [selectedTab] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.SPLIT_EXPENSE_TAB_TYPE}`, {canBeMissing: true});
const [draftTransaction] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`, {canBeMissing: false});
const [draftTransaction, draftTransactionMetadata] = useOnyx(`${ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT}${transactionID}`, {canBeMissing: false});
const isLoadingDraftTransaction = isLoadingOnyxValue(draftTransactionMetadata);
const transactionReport = getReportOrDraftReport(draftTransaction?.reportID);
const parentTransactionReport = getReportOrDraftReport(transactionReport?.parentReportID);
const expenseReport = transactionReport?.type === CONST.REPORT.TYPE.EXPENSE ? transactionReport : parentTransactionReport;
Expand Down Expand Up @@ -454,6 +457,10 @@ function SplitExpensePage({route}: SplitExpensePageProps) {
[draftTransaction, reportID],
);

if (isLoadingDraftTransaction) {
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ PERF-4 (docs)

Creating a new array [styles.opacity1] on each render breaks memoization of FullScreenLoadingIndicator, which is optimized by React Compiler.

Consider memoizing the style array:

const loadingIndicatorStyle = useMemo(() => [styles.opacity1], [styles.opacity1]);

// Then use it:
if (isLoadingDraftTransaction) {
    return <FullScreenLoadingIndicator style={loadingIndicatorStyle} />;
}

Alternatively, pass the style directly without an array wrapper:

return <FullScreenLoadingIndicator style={styles.opacity1} />;

return <FullScreenLoadingIndicator style={[styles.opacity1]} />;
}

return (
<ScreenWrapper
testID="SplitExpensePage"
Expand Down
Loading