Skip to content

Commit 4d0eeb2

Browse files
author
gabrieljablonski
committed
improve react suspense fallback
1 parent c13eb0b commit 4d0eeb2

File tree

6 files changed

+40
-19
lines changed

6 files changed

+40
-19
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"react-icons": "^4.3.1",
4848
"react-router-dom": "^6.3.0",
4949
"react-scripts": "^5.0.1",
50+
"react-spinners": "^0.13.3",
5051
"react-toastify": "^9.0.1",
5152
"short-uuid": "^4.2.0",
5253
"styled-components": "^5.3.5",

src/App.tsx

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
import React from 'react';
22
import { Slide } from 'react-toastify';
3+
import { BeatLoader } from 'react-spinners';
34
import { ModalDialog, ToastContainer } from './components';
45

56
import AppProvider from './providers';
67
import AppRoutes from './routes';
7-
import GlobalStyle from './styles/global';
8+
import GlobalStyle, { ColorPallete } from './styles/global';
89

910
const App: React.FC = () => {
1011
return (
1112
<AppProvider>
12-
<AppRoutes />
13-
<ToastContainer
14-
autoClose={5000}
15-
transition={Slide}
16-
newestOnTop
17-
closeOnClick
18-
draggable={false}
19-
pauseOnFocusLoss={false}
20-
pauseOnHover
21-
theme="dark"
22-
/>
23-
<ModalDialog />
13+
<React.Suspense
14+
fallback={
15+
<div
16+
style={{
17+
display: 'flex',
18+
height: '100%',
19+
width: '100%',
20+
alignItems: 'center',
21+
justifyContent: 'center',
22+
backgroundColor: ColorPallete.NEUTRAL_1,
23+
}}
24+
>
25+
<BeatLoader color={ColorPallete.NEUTRAL_3} />
26+
</div>
27+
}
28+
>
29+
<AppRoutes />
30+
<ToastContainer
31+
autoClose={5000}
32+
transition={Slide}
33+
newestOnTop
34+
closeOnClick
35+
draggable={false}
36+
pauseOnFocusLoss={false}
37+
pauseOnHover
38+
theme="dark"
39+
/>
40+
<ModalDialog />
41+
</React.Suspense>
2442
<GlobalStyle />
2543
</AppProvider>
2644
);

src/components/Input/styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export const StyledDivider = styled(Divider)<DividerProps>`
5151
margin: 8px;
5252
border-right-width: 1px;
5353
`;
54+
5455
export const StyledPaper = styled(Paper)<PaperStylesProps>`
5556
box-shadow: unset;
5657
padding: 2px 4px;

src/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ if (container) {
1010
const root = createRoot(container);
1111
root.render(
1212
<React.StrictMode>
13-
<React.Suspense fallback={<div />}>
14-
<App />
15-
</React.Suspense>
13+
<App />
1614
</React.StrictMode>,
1715
);
1816
}

src/styles/global.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ export default createGlobalStyle`
4949
outline: 0;
5050
font-family: 'Nunito', Arial, Helvetica, sans-serif;
5151
font-size: 16px;
52-
/* color: var(--color-neutral-3); */
5352
}
5453
5554
body {
56-
background: var(--color-neutral-1);
57-
/* color: #fff; */
55+
background-color: var(--color-neutral-1);
5856
-webkit-font-smoothing: antialiased;
5957
}
6058

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8574,6 +8574,11 @@ react-scripts@^5.0.1:
85748574
optionalDependencies:
85758575
fsevents "^2.3.2"
85768576

8577+
react-spinners@^0.13.3:
8578+
version "0.13.3"
8579+
resolved "https://registry.yarnpkg.com/react-spinners/-/react-spinners-0.13.3.tgz#9d00d10fb2a0869b21efdc13fb0fddbcecd05731"
8580+
integrity sha512-FHQMH6dAl1Vw4Lxv0H7hbGsjBs0aKNVwjGrDJLuD9R/C3h9+IuBhKJOJyCcegxMaLiBSBV96Tp+XV3OwPK8Vtw==
8581+
85778582
react-toastify@^9.0.1:
85788583
version "9.0.1"
85798584
resolved "https://registry.yarnpkg.com/react-toastify/-/react-toastify-9.0.1.tgz#2f3abd26a75efd55a82cb9c0a897c865218ea420"

0 commit comments

Comments
 (0)