import React from 'react'; import LoadingScreen from '../component'; interface LoadingContent { isLoading: boolean; loadingMessage: string; } interface LoadingContextContent extends LoadingContent { setLoading: (isLoading: boolean, loadingMessage: string) => void; } export const LoadingContext = React.createContext({ isLoading: false, loadingMessage: '', setLoading: () => { }, }); interface LoadingScreenHOCProps { children: React.ReactNode; } const LoadingScreenHOC: React.FC = ({ children, }) => { const [loading, setLoading] = React.useState({ isLoading: false, loadingMessage: '', }); return ( { setLoading({ isLoading, loadingMessage, }); }, }} > { loading.isLoading ? (

{loading.loadingMessage}

) : null } {children}
); }; export default LoadingScreenHOC;