Skip to content

Commit d1b357a

Browse files
authored
Migrate to React18 (#345)
* changes from running codemods * apply needed changes * update dependencies * use makeStyles from tss-react
1 parent f039fa7 commit d1b357a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2575
-2696
lines changed

client/package-lock.json

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

client/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
"@mui/base": "^5.0.0-beta.2",
1010
"@mui/icons-material": "^5.11.16",
1111
"@mui/material": "^5.13.2",
12-
"@mui/styles": "^5.13.2",
1312
"@testing-library/jest-dom": "^5.11.4",
1413
"@testing-library/react": "^11.1.0",
1514
"@testing-library/user-event": "^12.1.10",
1615
"@types/jest": "^26.0.23",
1716
"@types/jsonwebtoken": "^8.5.4",
1817
"@types/node": "^15.6.0",
19-
"@types/react-dom": "^17.0.2",
18+
"@types/react-dom": "^18.2.0",
2019
"@types/react-router-dom": "^5.1.7",
2120
"axios": "^0.26.1",
2221
"jest": "26.6.0",
2322
"jsonwebtoken": "^9.0.0",
24-
"react": "^17.0.2",
25-
"react-dom": "^17.0.2",
23+
"react": "^18.2.0",
24+
"react-dom": "^18.2.0",
2625
"react-hook-form": "^7.34.0",
2726
"react-input-mask": "^3.0.0-alpha.2",
2827
"react-query": "^3.35.0",
2928
"react-router-dom": "^5.2.0",
3029
"socket.io-client": "^4.5.1",
30+
"tss-react": "^4.8.4",
3131
"typescript": "^4.2.4",
3232
"web-vitals": "^1.0.1",
3333
"yup": "^0.32.11"
@@ -59,8 +59,8 @@
5959
"@types/jest": "^26.0.23",
6060
"@types/jsonwebtoken": "^8.5.4",
6161
"@types/node": "^15.6.0",
62-
"@types/react": "^17.0.2",
63-
"@types/react-dom": "^17.0.2",
62+
"@types/react": "^18.2.0",
63+
"@types/react-dom": "^18.2.0",
6464
"@types/react-input-mask": "^3.0.2",
6565
"@types/react-router-dom": "^5.1.7",
6666
"@typescript-eslint/eslint-plugin": "^5.5.0",

client/src/components/BannerSection.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Grid, Typography, Box } from '@mui/material';
2-
import { makeStyles } from '@mui/styles';
2+
import { makeStyles } from 'tss-react/mui';
33
import type { Theme } from '@mui/material/styles';
44
import MainImage from '../assets/banner-section-main.svg';
55
import CTAButton from './Buttons/CTAButton';
66

7-
const useStyles = makeStyles((theme: Theme) => ({
7+
const useStyles = makeStyles()((theme: Theme) => ({
88
gridTitle: {
99
backgroundColor: 'red',
1010
},
@@ -42,7 +42,7 @@ function BannerText() {
4242
}
4343

4444
function BannerSection() {
45-
const classes = useStyles();
45+
const { classes } = useStyles();
4646

4747
return (
4848
<Box>

client/src/components/Buttons/CTAButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { makeStyles } from '@mui/styles';
1+
import { makeStyles } from 'tss-react/mui';
22
import { Typography } from '@mui/material';
33
import type { Theme } from '@mui/material/styles';
44
import { useHistory } from 'react-router-dom';
55

6-
const useStyles = makeStyles((theme: Theme) => ({
6+
const useStyles = makeStyles()((theme: Theme) => ({
77
CTAButton: {
88
color: 'white',
99
backgroundColor: '#EF6A60',
@@ -23,7 +23,7 @@ type Props = {
2323
};
2424

2525
function CTAButton({ text }: Props) {
26-
const classes = useStyles();
26+
const { classes } = useStyles();
2727
const history = useHistory();
2828

2929
return (

client/src/components/CallToActionCard.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import Grid from '@mui/material/Grid';
44
import Card from '@mui/material/Card';
55
import CardContent from '@mui/material/CardContent';
66
import { Typography } from '@mui/material';
7-
import { makeStyles } from '@mui/styles';
7+
import { makeStyles } from 'tss-react/mui';
88
import { NavLink } from 'react-router-dom';
99

10-
const useStyles = makeStyles((theme) => ({
10+
const useStyles = makeStyles()((theme) => ({
1111
wrapper: {
1212
borderRadius: 5,
1313
},
@@ -42,7 +42,7 @@ type Props = {
4242
};
4343

4444
function CallToActionCard({ btnText, color, headerText, subText, to }: Props) {
45-
const classes = useStyles({});
45+
const { classes } = useStyles();
4646

4747
return (
4848
<Card className={classes.wrapper} sx={{ height: '500px', width: '100%' }}>

client/src/components/CallToActionCards.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import * as React from 'react';
22

33
import Grid from '@mui/material/Grid';
4-
import { makeStyles } from '@mui/styles';
4+
import { makeStyles } from 'tss-react/mui';
55

66
import CallToActionCard from './CallToActionCard';
77
import routes from '../routes/routes';
88

9-
const useStyles = makeStyles((theme) => ({
9+
const useStyles = makeStyles()((theme) => ({
1010
grid: {
1111
justifyContent: 'center',
1212
paddingTop: '25px',
1313
},
1414
}));
1515

1616
function CallToActionCards() {
17-
const classes = useStyles();
17+
const { classes } = useStyles();
1818

1919
return (
2020
<Grid className={classes.grid} container gap="20px">

client/src/components/Card/ProgressBar.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { makeStyles } from '@mui/styles';
1+
import { makeStyles } from 'tss-react/mui';
22

33
type Props = {
44
progress: number;
55
};
6-
const useStyles = makeStyles(() => ({
6+
// TODO jss-to-tss-react codemod: Unable to handle style definition reliably. ArrowFunctionExpression in CSS prop.
7+
const useStyles = makeStyles<{ progress: number }>()((_theme, { progress }) => ({
78
container: {
89
width: '10em',
910
height: 4,
@@ -12,16 +13,14 @@ const useStyles = makeStyles(() => ({
1213
overflow: 'hidden',
1314
},
1415
fill: {
15-
width: (props: Props) => {
16-
return `${props.progress}%`;
17-
},
16+
width: `${progress}%`,
1817
height: '100%',
1918
backgroundColor: '#43AFBF',
2019
},
2120
}));
2221

2322
export default function ProgressBar(props: Props) {
24-
const classes = useStyles(props);
23+
const { classes } = useStyles({ progress: props.progress });
2524

2625
return (
2726
<div className={classes.container}>

client/src/components/DisplayGrids/BulletGrid.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as React from 'react';
22
import Typography from '@mui/material/Typography';
3-
import { makeStyles } from '@mui/styles';
3+
import { makeStyles } from 'tss-react/mui';
44
import { Box, Grid } from '@mui/material';
55

66
import type { Theme } from '@mui/material/styles';
77

8-
const bulletStyles = makeStyles<Theme, BulletProps>((theme: Theme) => ({
8+
const bulletStyles = makeStyles()((theme: Theme) => ({
99
grid: {
1010
marginTop: '30px',
1111
},
@@ -22,7 +22,7 @@ type BulletProps = {
2222
};
2323

2424
function BulletGrid(props: BulletProps) {
25-
const classes = bulletStyles(props);
25+
const { classes } = bulletStyles();
2626

2727
return (
2828
<Grid container justifyContent="space-between">

client/src/components/DisplayGrids/GridImages.tsx

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as React from 'react';
22
import Typography from '@mui/material/Typography';
3-
import { makeStyles } from '@mui/styles';
3+
import { makeStyles } from 'tss-react/mui';
44
import { Box } from '@mui/material';
55

66
import type { Theme } from '@mui/material/styles';
77

8-
const useStyles = makeStyles<Theme, GridProps>((theme: Theme) => ({
8+
const useStyles = makeStyles()((theme: Theme) => ({
99
missionContent: {
1010
display: 'grid',
1111
gridTemplateColumns: 'repeat(7, 132px)',
@@ -41,7 +41,7 @@ type GridProps = {
4141
};
4242

4343
function GridImages(props: GridProps): JSX.Element {
44-
const classes = useStyles(props);
44+
const { classes } = useStyles();
4545

4646
return (
4747
<Box className={`${classes.missionContent}`}>
@@ -65,13 +65,14 @@ function GridImages(props: GridProps): JSX.Element {
6565

6666
// SUB-COMPONENT GridImage
6767

68-
const imageStyles = makeStyles<Theme, ImageProps>({
68+
// TODO jss-to-tss-react codemod: Unable to handle style definition reliably. ArrowFunctionExpression in CSS prop.
69+
const imageStyles = makeStyles<{ src: string }>()((_theme, { src }) => ({
6970
gridImage: {
7071
width: '100%',
7172
height: '109px',
7273
border: '1px solid black',
7374
backgroundColor: '#C4C4C4',
74-
backgroundImage: (props) => `url(${props.src})`,
75+
backgroundImage: `url(${src})`,
7576
backgroundSize: 'cover',
7677
backgroundPosition: 'center',
7778
},
@@ -84,15 +85,15 @@ const imageStyles = makeStyles<Theme, ImageProps>({
8485
gridRow: 'auto / span 1',
8586
},
8687
},
87-
});
88+
}));
8889

8990
type ImageProps = {
9091
src: string;
9192
isWide: boolean;
9293
};
9394

9495
function GridImage(props: ImageProps): JSX.Element {
95-
const classes = imageStyles(props);
96+
const { classes } = imageStyles({ src: props.src });
9697

9798
let wideClass = props.isWide === true ? classes.wideImage : '';
9899

@@ -101,33 +102,36 @@ function GridImage(props: ImageProps): JSX.Element {
101102

102103
// SUB-COMPONENT MissionStatement
103104

104-
const missionStyles = makeStyles<Theme, MissionProps>({
105-
missionText: {
106-
gridColumn: '5 / span 3',
107-
gridRow: (props) => `${props.row} / span 1`,
108-
textAlign: 'left',
109-
fontSize: '1.4rem',
110-
},
111-
'@media screen and (max-width: 1100px)': {
105+
// TODO jss-to-tss-react codemod: Unable to handle style definition reliably. ArrowFunctionExpression in CSS prop.
106+
const missionStyles = makeStyles<{ row: string }>()((_theme, { row }) => {
107+
return {
112108
missionText: {
113-
gridColumn: '4 / span 3',
109+
gridColumn: '5 / span 3',
110+
gridRow: `${row} / span 1`,
111+
textAlign: 'left',
112+
fontSize: '1.4rem',
114113
},
115-
},
116-
'@media screen and (max-width: 820px)': {
117-
missionText: {
118-
gridColumn: '1 / span 4',
119-
gridRow: 'auto / span 1',
114+
'@media screen and (max-width: 1100px)': {
115+
missionText: {
116+
gridColumn: '4 / span 3',
117+
},
120118
},
121-
},
122-
'@media screen and (max-width: 520px)': {
123-
missionText: {
124-
gridColumn: '1 / span 3',
119+
'@media screen and (max-width: 820px)': {
120+
missionText: {
121+
gridColumn: '1 / span 4',
122+
gridRow: 'auto / span 1',
123+
},
125124
},
126-
},
127-
missionTitle: {
128-
fontWeight: 'bold',
129-
fontSize: '1.4rem',
130-
},
125+
'@media screen and (max-width: 520px)': {
126+
missionText: {
127+
gridColumn: '1 / span 3',
128+
},
129+
},
130+
missionTitle: {
131+
fontWeight: 'bold',
132+
fontSize: '1.4rem',
133+
},
134+
};
131135
});
132136

133137
type MissionProps = {
@@ -137,7 +141,7 @@ type MissionProps = {
137141
};
138142

139143
function MissionStatement(props: MissionProps): JSX.Element {
140-
const classes = missionStyles(props);
144+
const { classes } = missionStyles({ row: props.row });
141145

142146
return (
143147
<Box className={`${classes.missionText}`}>

client/src/components/DisplayGrids/InstructionGrid.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as React from 'react';
22
import Typography from '@mui/material/Typography';
3-
import { makeStyles } from '@mui/styles';
3+
import { makeStyles } from 'tss-react/mui';
44
import { Grid } from '@mui/material';
55

6-
import type { Theme } from '@mui/material/styles';
7-
8-
const instructionStyles = makeStyles<Theme, InstructionProps>((theme: Theme) => ({
6+
const instructionStyles = makeStyles()(() => ({
97
gridBoxes: {
108
'& > div': {
119
width: '100%',
@@ -32,7 +30,7 @@ type InstructionProps = {
3230
};
3331

3432
function InstructionGrid(props: InstructionProps) {
35-
const classes = instructionStyles(props);
33+
const { classes } = instructionStyles();
3634

3735
return (
3836
<Grid container justifyContent="space-between" className={`${classes.gridBoxes}`}>

client/src/components/FAQs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { makeStyles } from '@mui/styles';
1+
import { makeStyles } from 'tss-react/mui';
22
import Typography from '@mui/material/Typography';
33
import Button from '@mui/material/Button';
44

@@ -15,7 +15,7 @@ const faqQuestions = [
1515
{ question: 'Other questions about this service?', answer: loremIpsum.slice(0, 150) },
1616
];
1717

18-
const useStyles = makeStyles(() => ({
18+
const useStyles = makeStyles()(() => ({
1919
faqs: {
2020
display: 'flex',
2121
height: 'auto',
@@ -53,7 +53,7 @@ const useStyles = makeStyles(() => ({
5353
}));
5454

5555
function FAQs() {
56-
const classes = useStyles();
56+
const { classes } = useStyles();
5757

5858
return (
5959
<div className={classes.faqs}>

client/src/components/FilterGroup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as React from 'react';
2-
import { makeStyles } from '@mui/styles';
2+
import { makeStyles } from 'tss-react/mui';
33
import Checkbox from '@mui/material/Checkbox';
44
import FormControlLabel from '@mui/material/FormControlLabel';
55
import Typography from '@mui/material/Typography';
66
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
77
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
88
import { Theme } from '@mui/material/styles';
99

10-
const useStyles = makeStyles((theme: Theme) => ({
10+
const useStyles = makeStyles()((theme: Theme) => ({
1111
wrapper: {
1212
padding: '0px 0px 5px 0px',
1313
position: 'relative',
@@ -34,7 +34,7 @@ type Props = {
3434
};
3535

3636
function FilterGroup(props: Props): JSX.Element {
37-
const classes = useStyles();
37+
const { classes } = useStyles();
3838
const { filters, header, onHandleCheck, selectedFilters } = props;
3939
let [expand, setExpand] = React.useState<boolean>(false);
4040

0 commit comments

Comments
 (0)