I have an app that needs to feature a dynamic header, loading an external file from a fetch request.
Once a user logs in they are directed to a portal /portal. I have defined a layout as:
export const UserLayout = ({ children }) => <div><Header /><div className="body">{children}</div></div>
This includes a header with includes dynamic links, then allows the route to be passed through so the header is not loaded every page change.
export const UserRoutes = () => {
return (
<UserLayout>
<Switch>
<Route path="/portal" exact component={Portal}/>
<Route path="/settings" exact component={Settings}/>
</Switch>
</UserLayout>
);
}
The header is first loaded after being redirect from /login to /portal.
I have setup in redux a global loader, which basically shows a full screen loading animation while fetching data.
The main issue I am having is, how can I load both parts of my application in a single request?
For example, the header loads the ajax content, which shows a redux loading animation, then stops. Then the route loads, which also shows a redux loading animation, then stops. This creates a flickering effect.
What is the best way to do this to have both the main part load and the child load at the same time?