Skip to content

Commit 682cf8b

Browse files
committed
Remove initialValue from useOnyx
1 parent b8ef627 commit 682cf8b

34 files changed

Lines changed: 54 additions & 62 deletions

src/components/ArchivedReportFooter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function ArchivedReportFooter({report}: ArchivedReportFooterProps) {
2121
const styles = useThemeStyles();
2222
const {translate} = useLocalize();
2323

24-
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {initialValue: {}});
24+
const [personalDetails = {}] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
2525
const [reportClosedAction] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report.reportID}`, {canEvict: false, selector: ReportActionsUtils.getLastClosedReportAction});
2626
const originalMessage = ReportActionsUtils.isClosedAction(reportClosedAction) ? ReportActionsUtils.getOriginalMessage(reportClosedAction) : null;
2727
const archiveReason = originalMessage?.reason ?? CONST.REPORT.ARCHIVE_REASON.DEFAULT;

src/components/FloatingActionButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function FloatingActionButton({onPress, isActive, accessibilityLabel, role, isTo
4646
const borderRadius = styles.floatingActionButton.borderRadius;
4747
const fabPressable = useRef<HTMLDivElement | View | Text | null>(null);
4848
const {shouldUseNarrowLayout} = useResponsiveLayout();
49-
const [isSidebarLoaded] = useOnyx(ONYXKEYS.IS_SIDEBAR_LOADED, {initialValue: false, canBeMissing: true});
49+
const [isSidebarLoaded = false] = useOnyx(ONYXKEYS.IS_SIDEBAR_LOADED, {canBeMissing: true});
5050
const isHomeRouteActive = useIsHomeRouteActive(shouldUseNarrowLayout);
5151
const {renderProductTrainingTooltip, shouldShowProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext(
5252
CONST.PRODUCT_TRAINING_TOOLTIP_NAMES.GLOBAL_CREATE_TOOLTIP,

src/components/MoneyReportHeader.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,12 @@ function MoneyReportHeader({
168168
}, [reportActions, transactionThreadReport?.parentReportActionID]);
169169
const [transactions = []] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {
170170
selector: (_transactions) => reportTransactionsSelector(_transactions, moneyRequestReport?.reportID),
171-
initialValue: [],
172171
canBeMissing: true,
173172
});
174173
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${isMoneyRequestAction(requestParentReportAction) && getOriginalMessage(requestParentReportAction)?.IOUTransactionID}`, {
175174
canBeMissing: true,
176175
});
177-
const [dismissedHoldUseExplanation, dismissedHoldUseExplanationResult] = useOnyx(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, {initialValue: true, canBeMissing: true});
176+
const [dismissedHoldUseExplanation = true, dismissedHoldUseExplanationResult] = useOnyx(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, {canBeMissing: true});
178177
const isLoadingHoldUseExplained = isLoadingOnyxValue(dismissedHoldUseExplanationResult);
179178

180179
const isExported = isExportedUtils(reportActions);

src/components/MoneyRequestHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, onBackButtonPre
8181

8282
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);
8383
const [downloadErrorModalVisible, setDownloadErrorModalVisible] = useState(false);
84-
const [dismissedHoldUseExplanation, dismissedHoldUseExplanationResult] = useOnyx(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, {initialValue: true, canBeMissing: false});
84+
const [dismissedHoldUseExplanation = true, dismissedHoldUseExplanationResult] = useOnyx(ONYXKEYS.NVP_DISMISSED_HOLD_USE_EXPLANATION, {canBeMissing: false});
8585
const [isLoadingReportData] = useOnyx(ONYXKEYS.IS_LOADING_REPORT_DATA, {canBeMissing: true});
8686
const isLoadingHoldUseExplained = isLoadingOnyxValue(dismissedHoldUseExplanationResult);
8787
const styles = useThemeStyles();

src/components/MoneyRequestReportView/MoneyRequestReportView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe
9090

9191
const reportID = report?.reportID;
9292
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true});
93-
const [isComposerFullSize] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`, {initialValue: false, canBeMissing: true});
93+
const [isComposerFullSize = false] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`, {canBeMissing: true});
9494
const {reportPendingAction, reportErrors} = getReportOfflinePendingActionAndErrors(report);
9595
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(report?.chatReportID)}`, {canBeMissing: true});
9696

src/components/ProductTrainingContext/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const ProductTrainingContext = createContext<ProductTrainingContextType>({
4949
});
5050

5151
function ProductTrainingContextProvider({children}: ChildrenProps) {
52-
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {initialValue: true, canBeMissing: true});
52+
const [isLoadingApp = true] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true});
5353
const [tryNewDot] = useOnyx(ONYXKEYS.NVP_TRY_NEW_DOT, {canBeMissing: true});
5454
const hasBeenAddedToNudgeMigration = !!tryNewDot?.nudgeMigration?.timestamp;
5555
const [isOnboardingCompleted = true, isOnboardingCompletedMetadata] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {

src/components/Reactions/MiniQuickEmojiReactions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ function MiniQuickEmojiReactions({reportAction, reportActionID, onEmojiSelected,
3737
const StyleUtils = useStyleUtils();
3838
const ref = useRef<View>(null);
3939
const {translate, preferredLocale} = useLocalize();
40-
const [preferredSkinTone] = useOnyx(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, {canBeMissing: true, initialValue: CONST.EMOJI_DEFAULT_SKIN_TONE});
41-
const [emojiReactions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, {canBeMissing: true, initialValue: {}});
40+
const [preferredSkinTone = CONST.EMOJI_DEFAULT_SKIN_TONE] = useOnyx(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, {canBeMissing: true});
41+
const [emojiReactions = {}] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, {canBeMissing: true});
4242

4343
const openEmojiPicker = () => {
4444
onPressOpenPicker();

src/components/Reactions/QuickEmojiReactions/BaseQuickEmojiReactions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ function BaseQuickEmojiReactions({
2323
}: BaseQuickEmojiReactionsProps) {
2424
const styles = useThemeStyles();
2525
const {preferredLocale} = useLocalize();
26-
const [preferredSkinTone] = useOnyx(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, {canBeMissing: true, initialValue: CONST.EMOJI_DEFAULT_SKIN_TONE});
27-
const [emojiReactions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, {canBeMissing: true, initialValue: {}});
26+
const [preferredSkinTone = CONST.EMOJI_DEFAULT_SKIN_TONE] = useOnyx(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, {canBeMissing: true});
27+
const [emojiReactions = {}] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`, {canBeMissing: true});
2828

2929
return (
3030
<View style={styles.quickReactionsContainer}>

src/components/SelectionList/Search/ReportListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function ReportListItem<TItem extends ListItem>({
3838
const theme = useTheme();
3939
const styles = useThemeStyles();
4040
const {translate} = useLocalize();
41-
const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {allowStaleData: true, initialValue: {}, canBeMissing: true});
41+
const [policies = {}] = useOnyx(ONYXKEYS.COLLECTION.POLICY, {allowStaleData: true, canBeMissing: true});
4242
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${reportItem?.policyID}`];
4343
const isEmptyReport = reportItem.transactions.length === 0;
4444
const isDisabledOrEmpty = isEmptyReport || isDisabled;

src/hooks/useOnboardingFlow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue';
1717
* Warning: This hook should be used only once in the app
1818
*/
1919
function useOnboardingFlowRouter() {
20-
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP, {initialValue: true, canBeMissing: true});
20+
const [isLoadingApp = true] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true});
2121
const [onboardingValues, isOnboardingCompletedMetadata] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {
2222
canBeMissing: true,
2323
});

0 commit comments

Comments
 (0)