From 6ea94143cd1bde060ee1743492c9db1023fb07b7 Mon Sep 17 00:00:00 2001 From: Turtuvshin Date: Mon, 25 Mar 2024 13:59:14 +0800 Subject: [PATCH] An error is displayed when there is a problem connecting to the backend --- src/features/Core/screens/BootScreen.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/features/Core/screens/BootScreen.js b/src/features/Core/screens/BootScreen.js index 5e9a513..ad1cc4a 100644 --- a/src/features/Core/screens/BootScreen.js +++ b/src/features/Core/screens/BootScreen.js @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { SafeAreaView, View, ActivityIndicator } from 'react-native'; import { initStripe } from '@stripe/stripe-react-native'; import { hasRequiredKeys, logError } from 'utils'; @@ -20,6 +20,7 @@ const { STRIPE_KEY, APP_IDENTIFIER } = config; * @component */ const BootScreen = ({ navigation }) => { + const [error, setError] = useState(null); // If the required keys are not provided display the setup warning screen if (!hasRequiredKeys()) { return ; @@ -54,6 +55,7 @@ const BootScreen = ({ navigation }) => { } }) .catch((error) => { + setError(error); logError(error, '[ Error fetching storefront info! ]'); }) .finally(() => { @@ -62,6 +64,10 @@ const BootScreen = ({ navigation }) => { }, 300); }); + if (error) { + return ; + } + return (