diff --git a/src/OfflineComponents/BlueBaseApp/BlueBaseApp.tsx b/src/OfflineComponents/BlueBaseApp/BlueBaseApp.tsx index 36dabe49..6945c65b 100644 --- a/src/OfflineComponents/BlueBaseApp/BlueBaseApp.tsx +++ b/src/OfflineComponents/BlueBaseApp/BlueBaseApp.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useCallback, useEffect, useState } from 'react'; import { BlueBase, BlueBaseProgress, BootOptions } from '../../BlueBase'; import { ErrorObserver } from '../../components'; @@ -61,7 +61,7 @@ export const BlueBaseApp = (props: BlueBaseAppProps) => { const { onError } = useExceptionHandlingOnProduction(BB); - async function boot(reset?: boolean) { + const boot = useCallback(async (reset?: boolean) => { if (!booting) { setBooting(true); } @@ -79,7 +79,7 @@ export const BlueBaseApp = (props: BlueBaseAppProps) => { }); setBootCount(bootCount + 1); setBooting(false); - } + }, [booting, bootCount, setBooting, setProgress, setBootCount, BB, props]); BB.reboot = async (reset: boolean = false) => { boot(reset); @@ -100,7 +100,7 @@ export const BlueBaseApp = (props: BlueBaseAppProps) => { } if (progress.error) { - return ; + return ; } return ( @@ -111,6 +111,7 @@ export const BlueBaseApp = (props: BlueBaseAppProps) => { progress={progress} bootCount={bootCount} onError={onError} + retry={boot} > diff --git a/src/OfflineComponents/BlueBaseAppError/BlueBaseAppError.tsx b/src/OfflineComponents/BlueBaseAppError/BlueBaseAppError.tsx index fb163c19..9ca147c7 100644 --- a/src/OfflineComponents/BlueBaseAppError/BlueBaseAppError.tsx +++ b/src/OfflineComponents/BlueBaseAppError/BlueBaseAppError.tsx @@ -17,9 +17,10 @@ export interface BlueBaseAppErrorProps { error?: Error; progress?: BlueBaseProgress; bootCount: number; + retry?: () => void; } -export const BlueBaseAppError = ({ progress, error: err, BB }: BlueBaseAppErrorProps) => { +export const BlueBaseAppError = ({ progress, error: err, retry }: BlueBaseAppErrorProps) => { const error = err || (progress && progress.error); let development = process.env.NODE_ENV !== 'production'; @@ -28,7 +29,6 @@ export const BlueBaseAppError = ({ progress, error: err, BB }: BlueBaseAppErrorP } const message = development === true && error ? error.message : MISSING_ERROR; - const reload = () => BB.reboot(); return ( @@ -64,7 +64,7 @@ export const BlueBaseAppError = ({ progress, error: err, BB }: BlueBaseAppErrorP {message} - +