Skip to content

Commit 064cafd

Browse files
authored
Merge pull request Expensify#85964 from callstack-internal/perf-scan-page/preload-fab-icons
perf-scan-page/Add preloading for FAB icons
2 parents 0d82803 + 9a2da80 commit 064cafd

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

jest/setup.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ jest.mock('../src/components/Icon/ExpensifyIconLoader.ts', () => ({
255255
};
256256
return Promise.resolve({default: mockIcon});
257257
}),
258+
loadExpensifyIconsChunk: jest.fn(() => Promise.resolve({})),
259+
getExpensifyIconsChunk: jest.fn(() => ({})),
260+
}));
261+
262+
jest.mock('../src/components/Icon/IllustrationLoader.ts', () => ({
263+
loadIllustration: jest.fn(() => Promise.resolve({default: {src: 'mock-illustration', height: 20, width: 20}})),
264+
loadIllustrationsChunk: jest.fn(() => Promise.resolve({})),
265+
getIllustrationsChunk: jest.fn(() => ({})),
258266
}));
259267

260268
jest.mock(

src/components/FloatingCameraButton/BaseFloatingCameraButton.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import React, {useState} from 'react';
1+
import React, {useEffect, useState} from 'react';
22
import {View} from 'react-native';
33
import type {OnyxCollection} from 'react-native-onyx';
44
import Icon from '@components/Icon';
5+
import {loadExpensifyIconsChunk} from '@components/Icon/ExpensifyIconLoader';
6+
import {loadIllustrationsChunk} from '@components/Icon/IllustrationLoader';
57
import {PressableWithoutFeedback} from '@components/Pressable';
68
import useLocalize from '@hooks/useLocalize';
79
import useOnyx from '@hooks/useOnyx';
@@ -33,6 +35,11 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) {
3335
const styles = useThemeStyles();
3436
const {translate} = useLocalize();
3537

38+
useEffect(() => {
39+
loadIllustrationsChunk().catch(() => {});
40+
loadExpensifyIconsChunk().catch(() => {});
41+
}, []);
42+
3643
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
3744
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`);
3845
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: sessionEmailAndAccountIDSelector});

0 commit comments

Comments
 (0)