Skip to content

Commit 75df65f

Browse files
committed
Make it a simple matter to replace the core Loader component entirely from src/app/main.js without necessarily adding additional bundle size to the shell.
1 parent cbde93c commit 75df65f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

.core/app/shell.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
export const Shell = async () => {
1+
export const Shell = async LoadingComponent => {
22
const { default: React, useRef } = await import('react');
33
const { default: _ } = await import('underscore');
44
const { createRoot } = await import('react-dom/client');
5-
const { Loading } = await import('../components/Loading');
5+
6+
let Loading;
7+
if (LoadingComponent) Loading = LoadingComponent;
8+
else {
9+
const mod = await import('../components/Loading');
10+
Loading = mod.Loading;
11+
}
612

713
const Shell = () => {
814
window.LoadingRef = useRef();
@@ -16,5 +22,10 @@ export const Shell = async () => {
1622
const { App } = await import('./index');
1723
await App();
1824

19-
_.defer(() => window.LoadingRef.current.setVisible(false));
25+
_.defer(
26+
() =>
27+
window.LoadingRef.current &&
28+
_.isFunction(window.LoadingRef.current.setVisible) &&
29+
window.LoadingRef.current.setVisible(false),
30+
);
2031
};

0 commit comments

Comments
 (0)