From 0ed1fe9fa115571eb35953cbc96bd3405975190f Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 20 Feb 2024 22:11:45 +0300 Subject: [PATCH 1/2] fix: add check before accessing a value --- __mocks__/@react-native-community/netinfo.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__mocks__/@react-native-community/netinfo.ts b/__mocks__/@react-native-community/netinfo.ts index 0b7bdc9010a3..15f2aeb1cfd3 100644 --- a/__mocks__/@react-native-community/netinfo.ts +++ b/__mocks__/@react-native-community/netinfo.ts @@ -2,12 +2,12 @@ import {NetInfoCellularGeneration, NetInfoStateType} from '@react-native-communi import type {addEventListener, configure, fetch, NetInfoState, refresh, useNetInfo} from '@react-native-community/netinfo'; const defaultState: NetInfoState = { - type: NetInfoStateType.cellular, + type: NetInfoStateType?.cellular, isConnected: true, isInternetReachable: true, details: { isConnectionExpensive: true, - cellularGeneration: NetInfoCellularGeneration['3g'], + cellularGeneration: NetInfoCellularGeneration ? NetInfoCellularGeneration['3g'] : null, carrier: 'T-Mobile', }, }; From 382eebb108a790ddf4d1f345cbd20ba5c37a2f82 Mon Sep 17 00:00:00 2001 From: Getabalew Tesfaye Date: Tue, 20 Feb 2024 22:24:51 +0300 Subject: [PATCH 2/2] chore: improve code --- __mocks__/@react-native-community/netinfo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__mocks__/@react-native-community/netinfo.ts b/__mocks__/@react-native-community/netinfo.ts index 15f2aeb1cfd3..db0d34e2276d 100644 --- a/__mocks__/@react-native-community/netinfo.ts +++ b/__mocks__/@react-native-community/netinfo.ts @@ -7,7 +7,7 @@ const defaultState: NetInfoState = { isInternetReachable: true, details: { isConnectionExpensive: true, - cellularGeneration: NetInfoCellularGeneration ? NetInfoCellularGeneration['3g'] : null, + cellularGeneration: NetInfoCellularGeneration?.['3g'], carrier: 'T-Mobile', }, };