Skip to content

Commit bf78c7c

Browse files
committed
refactor: use function for component
1 parent 200fc19 commit bf78c7c

15 files changed

+64
-81
lines changed

src/renderer/App.tsx

+16-16
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ import Player from '@/renderer/screens/Player';
77
import About from '@/renderer/screens/About';
88
import Settings from '@/renderer/screens/Settings';
99

10-
const App = () => (
11-
<HashRouter>
12-
<Routes>
13-
<Route path="/">
14-
<Route index element={<Main />} />
15-
<Route path="/explorer" element={<Explorer />} />
16-
<Route path="/player" element={<Player />} />
17-
<Route path="/settings" element={<Settings />} />
18-
<Route path="/about" element={<About />} />
19-
<Route path="*" element={<NotFound />} />
20-
</Route>
21-
</Routes>
22-
</HashRouter>
23-
);
24-
25-
export default App;
10+
export default function App() {
11+
return (
12+
<HashRouter>
13+
<Routes>
14+
<Route path="/">
15+
<Route index element={<Main />} />
16+
<Route path="/explorer" element={<Explorer />} />
17+
<Route path="/player" element={<Player />} />
18+
<Route path="/settings" element={<Settings />} />
19+
<Route path="/about" element={<About />} />
20+
<Route path="*" element={<NotFound />} />
21+
</Route>
22+
</Routes>
23+
</HashRouter>
24+
);
25+
}

src/renderer/components/dialogs/ModalConfirm.tsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ import { useTranslation } from 'react-i18next';
88

99
import { userSelectNone } from '@/renderer/utils/styles';
1010

11-
const ModalConfirm = ({ open = false, noCancel = false, onOk, onCancel, onClose, content }) => {
11+
export default function ModalConfirm({
12+
open = false,
13+
noCancel = false,
14+
onOk,
15+
onCancel,
16+
onClose,
17+
content,
18+
}) {
1219
const [t] = useTranslation(['common', 'notice', 'menu']);
1320

1421
const handleDialogClose = () => {
@@ -35,6 +42,4 @@ const ModalConfirm = ({ open = false, noCancel = false, onOk, onCancel, onClose,
3542
</DialogActions>
3643
</Dialog>
3744
);
38-
};
39-
40-
export default ModalConfirm;
45+
}

src/renderer/components/dialogs/ModalLocalStorageView.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { useMemo, useState } from 'react';
1717
import ModalConfirm from '@/renderer/components/dialogs/ModalConfirm';
1818
import { css } from '@emotion/react';
1919

20-
const ModalLocalStorageView = () => {
20+
export default function ModalLocalStorageView() {
2121
const [t] = useTranslation(['common', 'notice', 'menu']);
2222
const dispatch = useDispatch();
2323
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
@@ -128,6 +128,4 @@ const ModalLocalStorageView = () => {
128128
/>
129129
</>
130130
);
131-
};
132-
133-
export default ModalLocalStorageView;
131+
}

src/renderer/components/dialogs/ModalMetadata.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { userSelectNone } from '@/renderer/utils/styles';
1717
import { RootState } from '@/renderer/store';
1818
import { setConfig } from '@/renderer/store/slices/appScreenSlice';
1919

20-
const ModalMetadata = () => {
20+
export default function ModalMetadata() {
2121
const [t] = useTranslation(['common', 'notice', 'menu']);
2222
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
2323
const dispatch = useDispatch();
@@ -73,6 +73,4 @@ const ModalMetadata = () => {
7373
</DialogActions>
7474
</Dialog>
7575
);
76-
};
77-
78-
export default ModalMetadata;
76+
}

src/renderer/components/layouts/Header.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import ModalMetadata from '@/renderer/components/dialogs/ModalMetadata';
2020
import { buttonGroupButtonBase, marginRightXs } from '@/renderer/utils/styles';
2121
import { arrWithNumber } from '@/renderer/utils/helper';
2222

23-
const Header = ({ title, withBackButton, withRefresh = false }) => {
23+
export default function Header({ title, withBackButton, withRefresh = false }) {
2424
const navigate = useNavigate();
2525
const location = useLocation();
2626
const dispatch = useDispatch();
@@ -137,6 +137,4 @@ const Header = ({ title, withBackButton, withRefresh = false }) => {
137137
</Toolbar>
138138
</AppBar>
139139
);
140-
};
141-
142-
export default Header;
140+
}

src/renderer/components/layouts/Layout.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { headerArea } from '@/renderer/utils/styles';
99
import { useSelector } from 'react-redux';
1010
import { RootState } from '@/renderer/store';
1111

12-
const Layout = ({
12+
export default function Layout({
1313
title = 'Flare Player',
1414
titleTail = ' - Flare Flash Player',
1515
withTail = true,
@@ -19,7 +19,7 @@ const Layout = ({
1919
withPadding = true,
2020
withBackButton = false,
2121
children,
22-
}) => {
22+
}) {
2323
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
2424

2525
return (
@@ -71,6 +71,4 @@ const Layout = ({
7171
</Grid>
7272
</div>
7373
);
74-
};
75-
76-
export default Layout;
74+
}

src/renderer/components/layouts/ThemeContainer.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { useDispatch, useSelector } from 'react-redux';
1010
import { RootState } from '@/renderer/store';
1111
import { setConfig } from '@/renderer/store/slices/appScreenSlice';
1212

13-
const ThemeContainer = ({ children }) => {
13+
export default function ThemeContainer({ children }) {
1414
const dispatch = useDispatch();
1515
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
1616
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
@@ -111,6 +111,4 @@ const ThemeContainer = ({ children }) => {
111111
<ThemeProvider theme={muiTheme}>{children}</ThemeProvider>
112112
</MuiThemeProvider>
113113
);
114-
};
115-
116-
export default ThemeContainer;
114+
}

src/renderer/components/views/FlashPlayer.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import VolumeUp from '@mui/icons-material/VolumeUp';
1818
import { useTranslation } from 'react-i18next';
1919
import ModalConfirm from '@/renderer/components/dialogs/ModalConfirm';
2020

21-
const FlashPlayer = ({ url = '', autoplay = true, filePath = '', header = true }) => {
21+
export default function FlashPlayer({ url = '', autoplay = true, filePath = '', header = true }) {
2222
const [t] = useTranslation(['menu']);
2323
const navigate = useNavigate();
2424
const player: any = useRef(null);
@@ -246,6 +246,4 @@ const FlashPlayer = ({ url = '', autoplay = true, filePath = '', header = true }
246246
/>
247247
</>
248248
);
249-
};
250-
251-
export default FlashPlayer;
249+
}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/** @jsxImportSource @emotion/react */
22
import Typography from '@mui/material/Typography';
33

4-
const PanelHeader = ({ title, desc }) => (
5-
<>
6-
<Typography component="h3">{title}</Typography>
7-
<Typography component="span">{desc}</Typography>
8-
</>
9-
);
10-
11-
export default PanelHeader;
4+
export default function PanelHeader({ title, desc }) {
5+
return (
6+
<>
7+
<Typography component="h3">{title}</Typography>
8+
<Typography component="span">{desc}</Typography>
9+
</>
10+
);
11+
}

src/renderer/screens/About.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { paperBase } from '@/renderer/utils/styles';
1515
import { useSelector } from 'react-redux';
1616
import { RootState } from '@/renderer/store';
1717

18-
const About = () => {
18+
export default function About() {
1919
const [t] = useTranslation(['common', 'notice', 'menu']);
2020
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
2121
const ruffleVersion = useMemo(() => stateAppScreen.mainGlobalValues.APP_RUFFLE_VERSION_DATE, []);
@@ -60,6 +60,4 @@ const About = () => {
6060
</Grid>
6161
</Layout>
6262
);
63-
};
64-
65-
export default About;
63+
}

src/renderer/screens/Explorer.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { loadingText, paperSm } from '@/renderer/utils/styles';
2626
import { setConfig } from '@/renderer/store/slices/appScreenSlice';
2727
import useTheme from '@mui/material/styles/useTheme';
2828

29-
const Explorer = () => {
29+
export default function Explorer() {
3030
const dispatch = useDispatch();
3131
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
3232
const theme = useTheme();
@@ -259,6 +259,4 @@ const Explorer = () => {
259259
</Grid>
260260
</Layout>
261261
);
262-
};
263-
264-
export default Explorer;
262+
}

src/renderer/screens/Main.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { setConfig } from '@/renderer/store/slices/appScreenSlice';
1414
import { loadingText } from '@/renderer/utils/styles';
1515
import useTheme from '@mui/material/styles/useTheme';
1616

17-
const Main = () => {
17+
export default function Main() {
1818
const dispatch = useDispatch();
1919
const theme = useTheme();
2020
const [t, i18n] = useTranslation(['common']);
@@ -153,6 +153,4 @@ const Main = () => {
153153
</Grid>
154154
</Layout>
155155
);
156-
};
157-
158-
export default Main;
156+
}

src/renderer/screens/NotFound.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Link } from 'react-router-dom';
22

3-
const NotFound = () => (
4-
<div className="App">
5-
<h1>Unknown Error</h1>
6-
<Link to="/">Go to Main Page</Link>
7-
</div>
8-
);
9-
10-
export default NotFound;
3+
export default function NotFound() {
4+
return (
5+
<div className="App">
6+
<h1>Unknown Error</h1>
7+
<Link to="/">Go to Main Page</Link>
8+
</div>
9+
);
10+
}

src/renderer/screens/Player.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Layout from '@/renderer/components/layouts/Layout';
88
import FlashPlayer from '@/renderer/components/views/FlashPlayer';
99
import { setConfig } from '@/renderer/store/slices/appScreenSlice';
1010

11-
const Player = () => {
11+
export default function Player() {
1212
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
1313
const dispatch = useDispatch();
1414
const navigate = useNavigate();
@@ -43,6 +43,4 @@ const Player = () => {
4343
/>
4444
</Layout>
4545
);
46-
};
47-
48-
export default Player;
46+
}

src/renderer/screens/Settings.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import PanelHeader from '@/renderer/components/views/PanelHeader';
2222
import { setConfig } from '@/renderer/store/slices/appScreenSlice';
2323
import ModalLocalStorageView from '../components/dialogs/ModalLocalStorageView';
2424

25-
const Settings = () => {
25+
export default function Settings() {
2626
const stateAppScreen = useSelector((state: RootState) => state.appScreen);
2727
const dispatch = useDispatch();
2828
const [t, i18n] = useTranslation(['common', 'notice', 'menu']);
@@ -461,6 +461,4 @@ const Settings = () => {
461461
</Grid>
462462
</Layout>
463463
);
464-
};
465-
466-
export default Settings;
464+
}

0 commit comments

Comments
 (0)