accounts-frontend/packages/app/components/ui/bsod/BSoDContainer.tsx

30 lines
809 B
TypeScript
Raw Permalink Normal View History

import React, { ComponentType, useEffect, useState } from 'react';
import logger from 'app/services/logger/logger';
import BSoD from './BSoD';
const BSoDContainer: ComponentType = () => {
2020-05-24 04:38:24 +05:30
const [lastEventId, setLastEventId] = useState<string>();
useEffect(() => {
const timer = setInterval(() => {
// eslint-disable-next-line no-shadow
const lastEventId = logger.getLastEventId();
2020-05-24 04:38:24 +05:30
if (!lastEventId) {
return;
}
2020-05-24 04:38:24 +05:30
clearInterval(timer);
setLastEventId(lastEventId);
}, 500);
2020-05-24 04:38:24 +05:30
// Don't care about interval cleanup because there is no way from
// BSoD state and page can be only reloaded
}, []);
2020-05-24 04:38:24 +05:30
return <BSoD lastEventId={lastEventId} />;
};
export default BSoDContainer;