Skip to content

Commit a59a1d3

Browse files
committed
refactor(platform): use startup as Promise
1 parent 7608377 commit a59a1d3

4 files changed

Lines changed: 25 additions & 18 deletions

File tree

packages/platform/src/main.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import ReactDOMClient from 'react-dom/client';
33
import { BrowserRouter } from 'react-router-dom';
44

55
import App from './app/App';
6-
import './startup';
6+
import { startup } from './startup';
77

8-
const rootElement = document.getElementById('root') as Element;
8+
startup.then(() => {
9+
const rootElement = document.getElementById('root') as Element;
910

10-
ReactDOMClient.createRoot(rootElement).render(
11-
<StrictMode>
12-
<BrowserRouter>
13-
<App />
14-
</BrowserRouter>
15-
</StrictMode>
16-
);
11+
ReactDOMClient.createRoot(rootElement).render(
12+
<StrictMode>
13+
<BrowserRouter>
14+
<App />
15+
</BrowserRouter>
16+
</StrictMode>
17+
);
18+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { useStorage } from '@react-devui/hooks';
2+
3+
const STORAGE_KEY = '0';
4+
const storageKey = useStorage.SERVICE.getItem('storageKey');
5+
if (storageKey !== STORAGE_KEY) {
6+
useStorage.SERVICE.clear();
7+
useStorage.SERVICE.setItem('storageKey', STORAGE_KEY);
8+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-disable import/order */
2-
import './startup';
2+
import './config';
33

44
import './i18n';
5+
6+
export { startup } from './startup';
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import { useStorage } from '@react-devui/hooks';
2-
3-
const STORAGE_KEY = '0';
4-
const storageKey = useStorage.SERVICE.getItem('storageKey');
5-
if (storageKey !== STORAGE_KEY) {
6-
useStorage.SERVICE.clear();
7-
useStorage.SERVICE.setItem('storageKey', STORAGE_KEY);
8-
}
1+
export const startup = new Promise<void>((r) => {
2+
r();
3+
});

0 commit comments

Comments
 (0)