Skip to content

Commit 8d489e4

Browse files
authored
Merge pull request #60816 from software-mansion-labs/war-in/prepare-for-react-19
[Pre 0.79] Prepare for react 19
2 parents 89588cd + 20a5549 commit 8d489e4

File tree

28 files changed

+69
-69
lines changed

28 files changed

+69
-69
lines changed

src/components/AddPlaidBankAccount.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import useLocalize from '@hooks/useLocalize';
66
import useNetwork from '@hooks/useNetwork';
77
import useTheme from '@hooks/useTheme';
88
import useThemeStyles from '@hooks/useThemeStyles';
9+
import {handlePlaidError, openPlaidBankAccountSelector, openPlaidBankLogin, setPlaidEvent} from '@libs/actions/BankAccounts';
910
import KeyboardShortcut from '@libs/KeyboardShortcut';
1011
import Log from '@libs/Log';
11-
import * as App from '@userActions/App';
12-
import * as BankAccounts from '@userActions/BankAccounts';
12+
import {handleRestrictedEvent} from '@userActions/App';
1313
import CONST from '@src/CONST';
1414
import ONYXKEYS from '@src/ONYXKEYS';
1515
import type {PlaidData} from '@src/types/onyx';
@@ -91,7 +91,7 @@ function AddPlaidBankAccount({
9191
const defaultSelectedPlaidAccountID = defaultSelectedPlaidAccount?.plaidAccountID ?? '-1';
9292
const defaultSelectedPlaidAccountMask = plaidBankAccounts.find((account) => account.plaidAccountID === selectedPlaidAccountID)?.mask ?? '';
9393
const subscribedKeyboardShortcuts = useRef<Array<() => void>>([]);
94-
const previousNetworkState = useRef<boolean | undefined>();
94+
const previousNetworkState = useRef<boolean | undefined>(undefined);
9595
const [selectedPlaidAccountMask, setSelectedPlaidAccountMask] = useState(defaultSelectedPlaidAccountMask);
9696

9797
const {translate} = useLocalize();
@@ -149,7 +149,7 @@ function AddPlaidBankAccount({
149149
if (isAuthenticatedWithPlaid()) {
150150
return unsubscribeToNavigationShortcuts;
151151
}
152-
BankAccounts.openPlaidBankLogin(allowDebit, bankAccountID);
152+
openPlaidBankLogin(allowDebit, bankAccountID);
153153
return unsubscribeToNavigationShortcuts;
154154

155155
// disabling this rule, as we want this to run only on the first render
@@ -160,7 +160,7 @@ function AddPlaidBankAccount({
160160
// If we are coming back from offline and we haven't authenticated with Plaid yet, we need to re-run our call to kick off Plaid
161161
// previousNetworkState.current also makes sure that this doesn't run on the first render.
162162
if (previousNetworkState.current && !isOffline && !isAuthenticatedWithPlaid()) {
163-
BankAccounts.openPlaidBankLogin(allowDebit, bankAccountID);
163+
openPlaidBankLogin(allowDebit, bankAccountID);
164164
}
165165
previousNetworkState.current = isOffline;
166166
}, [allowDebit, bankAccountID, isAuthenticatedWithPlaid, isOffline]);
@@ -187,7 +187,7 @@ function AddPlaidBankAccount({
187187
onInputChange(plaidAccountID);
188188
};
189189

190-
const handlePlaidError = useCallback((error: ErrorEvent | null) => {
190+
const handlePlaidLinkError = useCallback((error: ErrorEvent | null) => {
191191
Log.hmmm('[PlaidLink] Error: ', error?.message);
192192
}, []);
193193

@@ -206,22 +206,22 @@ function AddPlaidBankAccount({
206206
token={token}
207207
onSuccess={({publicToken, metadata}) => {
208208
Log.info('[PlaidLink] Success!');
209-
BankAccounts.openPlaidBankAccountSelector(publicToken, metadata?.institution?.name ?? '', allowDebit, bankAccountID);
209+
openPlaidBankAccountSelector(publicToken, metadata?.institution?.name ?? '', allowDebit, bankAccountID);
210210
}}
211-
onError={handlePlaidError}
211+
onError={handlePlaidLinkError}
212212
onEvent={(event, metadata) => {
213-
BankAccounts.setPlaidEvent(event);
213+
setPlaidEvent(event);
214214
// Handle Plaid login errors (will potentially reset plaid token and item depending on the error)
215215
if (event === 'ERROR') {
216216
Log.hmmm('[PlaidLink] Error: ', {...metadata});
217217
if (bankAccountID && metadata && 'error_code' in metadata) {
218-
BankAccounts.handlePlaidError(bankAccountID, metadata.error_code ?? '', metadata.error_message ?? '', metadata.request_id);
218+
handlePlaidError(bankAccountID, metadata.error_code ?? '', metadata.error_message ?? '', metadata.request_id);
219219
}
220220
}
221221

222222
// Limit the number of times a user can submit Plaid credentials
223223
if (event === 'SUBMIT_CREDENTIALS') {
224-
App.handleRestrictedEvent(event);
224+
handleRestrictedEvent(event);
225225
}
226226
}}
227227
// User prematurely exited the Plaid flow

src/components/AttachmentPicker/index.native.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function AttachmentPicker({
109109
const theme = useTheme();
110110

111111
const completeAttachmentSelection = useRef<(data: FileObject[]) => void>(() => {});
112-
const onModalHide = useRef<() => void>();
112+
const onModalHide = useRef<(() => void) | undefined>(undefined);
113113
const onCanceled = useRef<() => void>(() => {});
114114
const onClosed = useRef<() => void>(() => {});
115115
const popoverRef = useRef(null);

src/components/DeeplinkWrapper/index.website.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function promptToOpenInDesktopApp(currentUserAccountID?: number, initialUrl = ''
4444
function DeeplinkWrapper({children, isAuthenticated, autoAuthState, initialUrl}: DeeplinkWrapperProps) {
4545
const [currentScreen, setCurrentScreen] = useState<string | undefined>();
4646
const [hasShownPrompt, setHasShownPrompt] = useState(false);
47-
const removeListener = useRef<() => void>();
47+
const removeListener = useRef<(() => void) | undefined>(undefined);
4848
const [isActingAsDelegate] = useOnyx(ONYXKEYS.ACCOUNT, {
4949
selector: (account) => !!account?.delegatedAccess?.delegate,
5050
canBeMissing: true,

src/components/EmojiPicker/EmojiPicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ function EmojiPicker({viewportOffsetTop}: EmojiPickerProps, ref: ForwardedRef<Em
4444
});
4545
const onModalHide = useRef<OnModalHideValue>(() => {});
4646
const onEmojiSelected = useRef<OnEmojiSelected>(() => {});
47-
const activeEmoji = useRef<string | undefined>();
48-
const emojiSearchInput = useRef<BaseTextInputRef | null>();
47+
const activeEmoji = useRef<string | undefined>(undefined);
48+
const emojiSearchInput = useRef<BaseTextInputRef | null>(null);
4949
const {windowHeight} = useWindowDimensions();
5050
const {shouldUseNarrowLayout} = useResponsiveLayout();
5151

src/components/Image/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function Image({source: propsSource, isAuthTokenRequired = false, onLoad, object
5252
/**
5353
* trying to figure out if the current session is expired or fresh from a necessary reauthentication
5454
*/
55-
const previousSessionAge = useRef<number | undefined>();
55+
const previousSessionAge = useRef<number | undefined>(undefined);
5656
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
5757
const validSessionAge: number | undefined = useMemo(() => {
5858
// Authentication is required only for certain types of images (attachments and receipts),

src/components/LHNOptionsList/OptionRowLHNData.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function OptionRowLHNData({
3737
const currentReportIDValue = useCurrentReportID();
3838
const isReportFocused = isFocused && currentReportIDValue?.currentReportID === reportID;
3939

40-
const optionItemRef = useRef<OptionData>();
40+
const optionItemRef = useRef<OptionData | undefined>(undefined);
4141

4242
const shouldDisplayViolations = shouldDisplayViolationsRBRInLHN(fullReport, transactionViolations);
4343
const isReportSettled = isSettled(fullReport);

src/components/MagicCodeInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function MagicCodeInput(
114114
) {
115115
const styles = useThemeStyles();
116116
const StyleUtils = useStyleUtils();
117-
const inputRef = useRef<BaseTextInputRef | null>();
117+
const inputRef = useRef<BaseTextInputRef | null>(null);
118118
const [input, setInput] = useState(TEXT_INPUT_EMPTY_STATE);
119119
const [focusedIndex, setFocusedIndex] = useState<number | undefined>(0);
120120
const editIndex = useRef(0);

src/components/Modal/BottomDockedModal/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function BottomDockedModal({
4242
const [deviceWidth, setDeviceWidth] = useState(() => Dimensions.get('window').width);
4343
const [deviceHeight, setDeviceHeight] = useState(() => Dimensions.get('window').height);
4444
const backHandlerListener = useRef<NativeEventSubscription | null>(null);
45-
const handleRef = useRef<number>();
45+
const handleRef = useRef<number | undefined>(undefined);
4646

4747
const styles = useThemeStyles();
4848

src/components/Navigation/TopLevelNavigationTabBar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function TopLevelNavigationTabBar({state}: TopLevelNavigationTabBarProps) {
3131
const {shouldUseNarrowLayout} = useResponsiveLayout();
3232
const {paddingBottom} = useSafeAreaPaddings();
3333
const [isAfterClosingTransition, setIsAfterClosingTransition] = useState(false);
34-
const cancelAfterInteractions = useRef<ReturnType<typeof InteractionManager.runAfterInteractions> | undefined>();
34+
const cancelAfterInteractions = useRef<ReturnType<typeof InteractionManager.runAfterInteractions> | undefined>(undefined);
3535
const {isBlockingViewVisible} = useContext(FullScreenBlockingViewContext);
3636
const {canUseLeftHandBar} = usePermissions();
3737
const StyleUtils = useStyleUtils();

src/components/PDFView/PDFPasswordForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function PDFPasswordForm({isFocused, isPasswordInvalid = false, shouldShowLoadin
4343
const [shouldShowForm, setShouldShowForm] = useState(false);
4444
const textInputRef = useRef<BaseTextInputRef>(null);
4545

46-
const focusTimeoutRef = useRef<NodeJS.Timeout>();
46+
const focusTimeoutRef = useRef<NodeJS.Timeout | undefined>(undefined);
4747

4848
const errorText = useMemo(() => {
4949
if (isPasswordInvalid) {

src/components/QRShare/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function QRShare({url, title, subtitle, logo, svgLogo, svgLogoFillColor, logoBac
2222
const qrCodeContainerWidth = shouldUseNarrowLayout ? windowWidth : variables.sideBarWidth;
2323

2424
const [qrCodeSize, setQrCodeSize] = useState<number>(qrCodeContainerWidth - styles.ph5.paddingHorizontal * 2 - variables.qrShareHorizontalPadding * 2);
25-
const svgRef = useRef<Svg>();
25+
const svgRef = useRef<Svg | undefined>(undefined);
2626

2727
useImperativeHandle(
2828
ref,

src/components/Search/SearchRouter/SearchRouterContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const Context = React.createContext<SearchRouterContext>(defaultSearchContext);
3030
function SearchRouterContextProvider({children}: ChildrenProps) {
3131
const [isSearchRouterDisplayed, setIsSearchRouterDisplayed] = useState(false);
3232
const searchRouterDisplayedRef = useRef(false);
33-
const searchPageInputRef = useRef<AnimatedTextInputRef>();
33+
const searchPageInputRef = useRef<AnimatedTextInputRef | undefined>(undefined);
3434

3535
const routerContext = useMemo(() => {
3636
const openSearchRouter = () => {

src/components/SettlementButton/AnimatedSettlementButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function AnimatedSettlementButton({
3838
const height = useSharedValue<number>(variables.componentSizeNormal);
3939
const [canShow, setCanShow] = React.useState(true);
4040
const [minWidth, setMinWidth] = React.useState<number>(0);
41-
const viewRef = useRef<HTMLElement | null>();
41+
const viewRef = useRef<HTMLElement | null>(null);
4242

4343
const containerStyles = useAnimatedStyle(() => ({
4444
height: height.get(),

src/components/Tooltip/EducationalTooltip/BaseEducationalTooltip.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ type ScrollingEventData = {
2020
* This tooltip would show immediately without user's interaction and hide after 5 seconds.
2121
*/
2222
function BaseEducationalTooltip({children, shouldRender = false, shouldHideOnNavigate = true, shouldHideOnScroll = false, ...props}: EducationalTooltipProps) {
23-
const genericTooltipStateRef = useRef<GenericTooltipState>();
24-
const tooltipElementRef = useRef<Readonly<NativeMethods>>();
23+
const genericTooltipStateRef = useRef<GenericTooltipState | undefined>(undefined);
24+
const tooltipElementRef = useRef<Readonly<NativeMethods> | undefined>(undefined);
2525

2626
const [shouldMeasure, setShouldMeasure] = useState(false);
27-
const show = useRef<() => void>();
27+
const show = useRef<(() => void) | undefined>(undefined);
2828

2929
const navigator = useContext(NavigationContext);
3030
const insets = useSafeAreaInsets();

src/components/ValidateCodeActionModal/ValidateCodeForm/BaseValidateCodeForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function BaseValidateCodeForm({
128128
const [validateCodeAction] = useOnyx(ONYXKEYS.VALIDATE_ACTION_CODE, {canBeMissing: true});
129129
const validateCodeSent = useMemo(() => hasMagicCodeBeenSent ?? validateCodeAction?.validateCodeSent, [hasMagicCodeBeenSent, validateCodeAction?.validateCodeSent]);
130130
const latestValidateCodeError = getLatestErrorField(validateCodeAction, validateCodeActionErrorField);
131-
const timerRef = useRef<NodeJS.Timeout>();
131+
const timerRef = useRef<NodeJS.Timeout | undefined>(undefined);
132132

133133
useImperativeHandle(innerRef, () => ({
134134
focus() {

src/components/VideoPlayer/BaseVideoPlayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ function BaseVideoPlayer({
336336
currentVideoPlayerRef.current = videoPlayerRef.current;
337337
}, [url, currentVideoPlayerRef, isUploading, pauseVideo]);
338338

339-
const isCurrentlyURLSetRef = useRef<boolean>();
339+
const isCurrentlyURLSetRef = useRef<boolean | undefined>(undefined);
340340
isCurrentlyURLSetRef.current = isCurrentlyURLSet;
341341

342342
useEffect(

src/components/VideoPlayerContexts/PlaybackContext/usePlaybackContextVideoRefs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {PlaybackContextVideoRefs, PlayVideoPromiseRef, StopVideo, UnloadVid
66
function usePlaybackContextVideoRefs(resetCallback: () => void) {
77
const currentVideoPlayerRef: PlaybackContextVideoRefs['ref'] = useRef(null);
88
const videoResumeTryNumberRef: PlaybackContextVideoRefs['resumeTryNumberRef'] = useRef(0);
9-
const playVideoPromiseRef: PlayVideoPromiseRef = useRef();
9+
const playVideoPromiseRef: PlayVideoPromiseRef = useRef(undefined);
1010
const isPlayPendingRef = useRef(false);
1111

1212
const pauseVideo: PlaybackContextVideoRefs['pause'] = useCallback(() => {

src/hooks/useDebounce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type GenericFunction = (...args: any[]) => void;
2121
* @returns Returns a function to call the debounced function.
2222
*/
2323
export default function useDebounce<T extends GenericFunction>(func: T, wait: number, options?: DebounceSettings): T {
24-
const debouncedFnRef = useRef<DebouncedFunc<T>>();
24+
const debouncedFnRef = useRef<DebouncedFunc<T> | undefined>(undefined);
2525
const {leading, maxWait, trailing = true} = options ?? {};
2626

2727
useEffect(() => {

src/hooks/useDebounceNonReactive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type GenericFunction = (...args: any[]) => void;
2323
*/
2424
export default function useDebounceNonReactive<T extends GenericFunction>(func: T, wait: number, options?: DebounceSettings): T {
2525
const funcRef = useRef<T>(func); // Store the latest func reference
26-
const debouncedFnRef = useRef<DebouncedFunc<T>>();
26+
const debouncedFnRef = useRef<DebouncedFunc<T> | undefined>(undefined);
2727
const {leading, maxWait, trailing = true} = options ?? {};
2828

2929
useEffect(() => {

src/hooks/useDeepCompareRef.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {useRef} from 'react';
1616
* }, [deepComparedArray]);
1717
*/
1818
export default function useDeepCompareRef<T>(value: T): T | undefined {
19-
const ref = useRef<T>();
19+
const ref = useRef<T | undefined>(undefined);
2020
// eslint-disable-next-line react-compiler/react-compiler
2121
if (!isEqual(value, ref.current)) {
2222
// eslint-disable-next-line react-compiler/react-compiler

src/hooks/useSingleExecution/index.native.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type Action<T extends unknown[]> = (...params: T) => void | Promise<void>;
88
*/
99
export default function useSingleExecution() {
1010
const [isExecuting, setIsExecuting] = useState(false);
11-
const isExecutingRef = useRef<boolean>();
11+
const isExecutingRef = useRef<boolean | undefined>(undefined);
1212

1313
// eslint-disable-next-line react-compiler/react-compiler
1414
isExecutingRef.current = isExecuting;

src/libs/actions/IOU.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4377,7 +4377,7 @@ function updateMoneyRequestTag(
43774377
/** Updates the created tax amount of an expense */
43784378
function updateMoneyRequestTaxAmount(
43794379
transactionID: string,
4380-
optimisticReportActionID: string,
4380+
optimisticReportActionID: string | undefined,
43814381
taxAmount: number,
43824382
policy: OnyxEntry<OnyxTypes.Policy>,
43834383
policyTagList: OnyxEntry<OnyxTypes.PolicyTagLists>,

src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ function extractPointerEvent(event: GestureResponderEvent | MouseEvent): MouseEv
3434

3535
function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<ReportActionContextMenu>) {
3636
const {translate} = useLocalize();
37-
const reportIDRef = useRef<string | undefined>();
38-
const typeRef = useRef<ContextMenuType>();
37+
const reportIDRef = useRef<string | undefined>(undefined);
38+
const typeRef = useRef<ContextMenuType | undefined>(undefined);
3939
const reportActionRef = useRef<NonNullable<OnyxEntry<ReportAction>> | null>(null);
40-
const reportActionIDRef = useRef<string | undefined>();
41-
const originalReportIDRef = useRef<string | undefined>();
40+
const reportActionIDRef = useRef<string | undefined>(undefined);
41+
const originalReportIDRef = useRef<string | undefined>(undefined);
4242
const selectionRef = useRef('');
43-
const reportActionDraftMessageRef = useRef<string>();
43+
const reportActionDraftMessageRef = useRef<string | undefined>(undefined);
4444

4545
const cursorRelativePosition = useRef({
4646
horizontal: 0,

src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function ComposerWithSuggestionsE2e(props: ComposerWithSuggestionsProps, ref: Fo
2626
// for this component. This file is only used for e2e tests, so it's okay to
2727
// disable compiler for this file.
2828

29-
const textInputRef = useRef<ComposerRef | null>();
29+
const textInputRef = useRef<ComposerRef | null>(null);
3030
const hasFocusBeenRequested = useRef(false);
3131
const onLayout = useCallback((event: LayoutChangeEvent) => {
3232
const testConfig = E2EClient.getCurrentActiveTestConfig();
@@ -78,7 +78,7 @@ function ComposerWithSuggestionsE2e(props: ComposerWithSuggestionsProps, ref: Fo
7878
}}
7979
onLayout={onLayout}
8080
>
81-
{/* Important:
81+
{/* Important:
8282
this has to be a child, as this container might not
8383
re-render while the actual ComposerWithSuggestions will.
8484
*/}

src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ function ReportActionCompose({
168168
const [exceededMaxLength, setExceededMaxLength] = useState<number | null>(null);
169169

170170
const suggestionsRef = useRef<SuggestionsRef>(null);
171-
const composerRef = useRef<ComposerRef>();
171+
const composerRef = useRef<ComposerRef | undefined>(undefined);
172172
const reportParticipantIDs = useMemo(
173173
() =>
174174
Object.keys(report?.participants ?? {})

src/pages/iou/request/step/DiscardChangesConfirmation/index.native.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type DiscardChangesConfirmationProps from './types';
99
function DiscardChangesConfirmation({getHasUnsavedChanges}: DiscardChangesConfirmationProps) {
1010
const {translate} = useLocalize();
1111
const [isVisible, setIsVisible] = useState(false);
12-
const blockedNavigationAction = useRef<NavigationAction>();
12+
const blockedNavigationAction = useRef<NavigationAction | undefined>(undefined);
1313

1414
useBeforeRemove(
1515
useCallback(

0 commit comments

Comments
 (0)