Skip to content

Commit 8e2f3ff

Browse files
authored
Merge pull request #420 from topcoder-platform/TCA-642_delay-header-footer-rendering
TCA-642 - delay the rendering for the header and footer elements -> dev
2 parents adf197f + e8ccb53 commit 8e2f3ff

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src-ts/App.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, ReactElement, useContext } from 'react'
1+
import { Dispatch, FC, ReactElement, SetStateAction, useContext, useEffect, useState } from 'react'
22
import { Routes } from 'react-router-dom'
33
import { toast, ToastContainer } from 'react-toastify'
44

@@ -7,11 +7,22 @@ import { routeContext, RouteContextData } from './lib'
77

88
const App: FC<{}> = () => {
99

10+
const [ready, setReady]: [boolean, Dispatch<SetStateAction<boolean>>] = useState(false)
1011
const { allRoutes, getRouteElement }: RouteContextData = useContext(routeContext)
1112

1213
const routeElements: Array<ReactElement> = allRoutes
1314
.map(route => getRouteElement(route))
1415

16+
useEffect(() => {
17+
setReady(true)
18+
}, [])
19+
20+
useEffect(() => {
21+
if (ready) {
22+
document.getElementById('root')?.classList.add('app-ready');
23+
}
24+
}, [ready]);
25+
1526
return (
1627
<>
1728
<Header />

src-ts/header/Header.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
.header-wrap {
44
display: block;
55
background-color: $tc-black;
6+
7+
:global(#root:not(.app-ready)) & {
8+
display: none;
9+
}
610
}
711

812
.header {

src-ts/lib/page-footer/PageFooter.module.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
.footer-wrap {
55
height: $footer-height;
66
border-top: $border-xs solid $black-10;
7+
8+
:global(#root:not(.app-ready)) & {
9+
display: none;
10+
}
711
}
812

913
.footer-inner {
@@ -37,7 +41,7 @@
3741
@include ltesm {
3842
flex-direction: column;
3943
gap: $space-sm;
40-
44+
4145
> div > * + * {
4246
margin-left: $space-sm;
4347
}

0 commit comments

Comments
 (0)