Skip to content

Commit c188d95

Browse files
authored
Merge pull request #15 from karpolan/dev
Ver 0.5.55 - React 19
2 parents 9be7cfa + ff418e1 commit c188d95

File tree

7 files changed

+76
-91
lines changed

7 files changed

+76
-91
lines changed

package-lock.json

Lines changed: 19 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"name": "react-mui-vite-ts",
4-
"version": "0.4.41",
4+
"version": "0.5.55",
55
"description": "Starter project for Vite with React + MUI using TypeScript",
66
"author": {
77
"name": "Anton Karpenko",
@@ -26,8 +26,8 @@
2626
"@mui/icons-material": "latest",
2727
"@mui/material": "latest",
2828
"copy-to-clipboard": "latest",
29-
"react": "^18",
30-
"react-dom": "^18",
29+
"react": "^19",
30+
"react-dom": "^19",
3131
"react-router-dom": "latest"
3232
},
3333
"devDependencies": {

src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ThemeProvider } from '@/theme';
2-
import StoreProvider from '@/store';
31
import { ErrorBoundary } from '@/components';
42
import Routes from '@/routes';
3+
import StoreProvider from '@/store';
4+
import { ThemeProvider } from '@/theme';
55

66
/**
77
* Root Application Component
Lines changed: 45 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { forwardRef, useMemo } from 'react';
1+
import { FunctionComponent, useMemo } from 'react';
22
import { Link as RouterLink, useLocation } from 'react-router-dom';
33
import MuiLink, { LinkProps as MuiLinkProps } from '@mui/material/Link';
44
import { APP_LINK_COLOR, APP_LINK_UNDERLINE } from '@/components/config';
@@ -19,58 +19,53 @@ export interface AppLinkProps extends MuiLinkProps {
1919
* @param {string} [href] - external link URI
2020
* @param {boolean} [openInNewTab] - link will be opened in new tab when true
2121
*/
22-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
23-
const AppLink = forwardRef<any, AppLinkProps>(
24-
(
25-
{
26-
activeClassName = 'active', // This class is applied to the Link component when the router.pathname matches the href/to prop
27-
children,
28-
color = APP_LINK_COLOR,
29-
className: customClassName,
30-
underline = APP_LINK_UNDERLINE,
31-
to,
32-
href,
33-
openInNewTab, // Note: all external links are open in new Tab by default
34-
...restOfProps
35-
},
36-
ref
37-
) => {
38-
const location = useLocation();
39-
const currentPath = location.pathname;
40-
const destination = to || href || ''; // Note: Don't use ?? here!!!
22+
const AppLink: FunctionComponent<AppLinkProps> = ({
23+
activeClassName = 'active', // This class is applied to the Link component when the router.pathname matches the href/to prop
24+
children,
25+
color = APP_LINK_COLOR,
26+
className: customClassName,
27+
underline = APP_LINK_UNDERLINE,
28+
to,
29+
href,
30+
openInNewTab, // Note: all external links are open in new Tab by default
31+
ref,
32+
...restOfProps
33+
}) => {
34+
const location = useLocation();
35+
const currentPath = location.pathname;
36+
const destination = to || href || ''; // Note: Don't use ?? here!!!
4137

42-
const className = useMemo(
43-
() => [customClassName, destination == currentPath && activeClassName].filter(Boolean).join(' '),
44-
[customClassName, activeClassName, destination, currentPath]
45-
);
38+
const className = useMemo(
39+
() => [customClassName, destination == currentPath && activeClassName].filter(Boolean).join(' '),
40+
[customClassName, activeClassName, destination, currentPath]
41+
);
4642

47-
const isExternal = useMemo(
48-
() =>
49-
destination.startsWith('http') ||
50-
destination.startsWith('//') ||
51-
destination.startsWith('mailto:') ||
52-
destination.startsWith('tel:'),
53-
[destination]
54-
);
43+
const isExternal = useMemo(
44+
() =>
45+
destination.startsWith('http') ||
46+
destination.startsWith('//') ||
47+
destination.startsWith('mailto:') ||
48+
destination.startsWith('tel:'),
49+
[destination]
50+
);
5551

56-
const propsToRender = {
57-
className,
58-
color,
59-
underline, // 'hover' | 'always' | 'none'
60-
...((openInNewTab || (isExternal && openInNewTab !== false)) && EXTERNAL_LINK_PROPS), // Open external links in new tab
61-
...restOfProps,
62-
};
52+
const propsToRender = {
53+
className,
54+
color,
55+
underline, // 'hover' | 'always' | 'none'
56+
...((openInNewTab || (isExternal && openInNewTab !== false)) && EXTERNAL_LINK_PROPS), // Open external links in new tab
57+
...restOfProps,
58+
};
6359

64-
return isExternal ? (
65-
<MuiLink ref={ref} href={destination} {...propsToRender}>
66-
{children}
67-
</MuiLink>
68-
) : (
69-
<MuiLink ref={ref} component={RouterLink} to={destination} {...propsToRender}>
70-
{children}
71-
</MuiLink>
72-
);
73-
}
74-
);
60+
return isExternal ? (
61+
<MuiLink ref={ref} href={destination} {...propsToRender}>
62+
{children}
63+
</MuiLink>
64+
) : (
65+
<MuiLink ref={ref} component={RouterLink} to={destination} {...propsToRender}>
66+
{children}
67+
</MuiLink>
68+
);
69+
};
7570

7671
export default AppLink;

src/main.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React from 'react';
1+
import { StrictMode } from 'react';
22
import ReactDOM from 'react-dom/client';
33
import MainApp from './App.tsx';
44
import './default.css';
55

66
ReactDOM.createRoot(document.getElementById('root')!).render(
7-
<React.StrictMode>
7+
<StrictMode>
88
<MainApp />
9-
</React.StrictMode>
9+
</StrictMode>
1010
);

src/store/AppStoreProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FunctionComponent, PropsWithChildren, useReducer } from 'react';
2+
import { AppStoreState, INITIAL_APP_STORE_STATE } from './config';
23
import { AppContextReturningType, AppStoreContext } from './AppStore';
34
import AppStoreReducer from './AppStoreReducer';
4-
import { AppStoreState, INITIAL_APP_STORE_STATE } from './config';
55

66
/**
77
* Main global Store as HOC with React Context API
@@ -21,7 +21,7 @@ const AppStoreProvider: FunctionComponent<PropsWithChildren> = ({ children }) =>
2121
};
2222
const value: AppContextReturningType = useReducer(AppStoreReducer, initialState);
2323

24-
return <AppStoreContext.Provider value={value}>{children}</AppStoreContext.Provider>;
24+
return <AppStoreContext value={value}>{children}</AppStoreContext>;
2525
};
2626

2727
export default AppStoreProvider;

src/views/Dev/components/DemoDialogs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ const DemoDialogs = () => {
9696
);
9797
};
9898

99-
const onEditEmailDialogClose = useCallback((data: unknown) => {
100-
console.info('onEditEmailDialogClose() - data:', data);
99+
const onEditEmailDialogClose = useCallback(() => {
100+
console.info('onEditEmailDialogClose() - email:', email);
101101
setOpenEmailDialog(false);
102102
}, []);
103103

0 commit comments

Comments
 (0)