From 0fcadf6699938256a706c7c32c986099ccc5ccd7 Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Tue, 7 Nov 2023 13:43:50 +0100 Subject: [PATCH 1/2] migrate usePrivatePersonalDetails to TypeScript --- ...tePersonalDetails.js => usePrivatePersonalDetails.ts} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename src/hooks/{usePrivatePersonalDetails.js => usePrivatePersonalDetails.ts} (64%) diff --git a/src/hooks/usePrivatePersonalDetails.js b/src/hooks/usePrivatePersonalDetails.ts similarity index 64% rename from src/hooks/usePrivatePersonalDetails.js rename to src/hooks/usePrivatePersonalDetails.ts index 04d90f1ce5de..304708a5c0b3 100644 --- a/src/hooks/usePrivatePersonalDetails.js +++ b/src/hooks/usePrivatePersonalDetails.ts @@ -1,5 +1,4 @@ import {useContext, useEffect} from 'react'; -import _ from 'underscore'; import {NetworkContext} from '@components/OnyxProvider'; import * as PersonalDetails from '@userActions/PersonalDetails'; @@ -7,13 +6,15 @@ import * as PersonalDetails from '@userActions/PersonalDetails'; * Hook for fetching private personal details */ export default function usePrivatePersonalDetails() { - const {isOffline} = useContext(NetworkContext); + const network = useContext(NetworkContext); useEffect(() => { const personalDetails = PersonalDetails.getPrivatePersonalDetails(); - if (isOffline || (Boolean(personalDetails) && !_.isUndefined(personalDetails.isLoading))) { + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + if (network?.isOffline || (Boolean(personalDetails) && personalDetails?.isLoading !== undefined)) { return; } + PersonalDetails.openPersonalDetailsPage(); - }, [isOffline]); + }, [network]); } From d5f72f82960b95b4c66b1db4b530a86f943f29ba Mon Sep 17 00:00:00 2001 From: Julian Kobrynski Date: Tue, 7 Nov 2023 14:21:06 +0100 Subject: [PATCH 2/2] remove object from dependency array --- src/hooks/usePrivatePersonalDetails.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/usePrivatePersonalDetails.ts b/src/hooks/usePrivatePersonalDetails.ts index 304708a5c0b3..89d9951cef11 100644 --- a/src/hooks/usePrivatePersonalDetails.ts +++ b/src/hooks/usePrivatePersonalDetails.ts @@ -16,5 +16,5 @@ export default function usePrivatePersonalDetails() { } PersonalDetails.openPersonalDetailsPage(); - }, [network]); + }, [network?.isOffline]); }