Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Upgrade to React 19 #3088

Merged
merged 25 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
13dc2ad
migrate to react 19
aligg Dec 23, 2024
7da47b0
format
aligg Dec 23, 2024
d1ba82b
denote 19 in package file
aligg Dec 23, 2024
58f3089
update jsx references
aligg Dec 23, 2024
bea813a
Merge branch 'main' into aligg/19
aligg Mar 11, 2025
6ef3076
Optimize react 19 migration types to custom legacy types
jpandersen87 Mar 13, 2025
205d97f
merge
jpandersen87 Mar 13, 2025
d55ec97
merge fixes
jpandersen87 Mar 13, 2025
c45095a
fix snapshots
jpandersen87 Mar 13, 2025
8349f31
use JSX.Element as functional component returns
jpandersen87 Mar 13, 2025
5746c7a
with typo
aligg Mar 13, 2025
4b821bd
remove lock file package.json
aligg Mar 13, 2025
5cdb9ce
Merge branch 'aligg/19' into jpandersen87/19
jpandersen87 Mar 13, 2025
edcbf09
fix accidental newline
jpandersen87 Mar 13, 2025
d42888b
Merge pull request #1 from jpandersen87/jpandersen87/19
aligg Mar 13, 2025
ad25431
Merge branch 'main' into aligg/19
aligg Mar 13, 2025
0f71cc5
update dependencies
jpandersen87 Mar 13, 2025
cb0e84e
Merge branch 'main' into jpandersen87/19
jpandersen87 Mar 14, 2025
940cee6
Merge pull request #2 from jpandersen87/jpandersen87/19
aligg Mar 14, 2025
5cceb3d
Merge branch 'main' into jpandersen87/19
jpandersen87 Mar 14, 2025
f6a6781
Merge pull request #3 from jpandersen87/jpandersen87/19
aligg Mar 14, 2025
01562db
fix happo
jpandersen87 Mar 14, 2025
d209289
Merge pull request #4 from jpandersen87/jpandersen87/19
aligg Mar 14, 2025
f8e0067
Merge branch 'main' into jpandersen87/19
jpandersen87 Mar 17, 2025
ad67085
Merge pull request #5 from jpandersen87/jpandersen87/19
aligg Mar 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .happo.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const { RemoteBrowserTarget } = require('happo.io')
const happoPluginStorybook = require('happo-plugin-storybook')

require('dotenv').config()

module.exports = {
apiKey: process.env.HAPPO_API_KEY,
apiSecret: process.env.HAPPO_API_SECRET,
Expand Down
10 changes: 7 additions & 3 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"plugins": ["stylelint-prettier"],
"plugins": [],
"rules": {
"at-rule-no-unknown": null,
"scss/at-rule-no-unknown": true,
"prettier/prettier": true,
"selector-class-pattern": "",
"scss/function-no-unknown": null,
"at-rule-empty-line-before": null
},
"extends": ["stylelint-config-recommended", "stylelint-prettier/recommended", "stylelint-config-sass-guidelines", "stylelint-config-css-modules", "stylelint-config-standard-scss"]
"extends": [
"stylelint-config-recommended",
"stylelint-config-sass-guidelines",
"stylelint-config-css-modules",
"stylelint-config-standard-scss"
]
}
49 changes: 22 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,36 @@
},
"homepage": "https://github.com/trussworks/react-uswds#readme",
"peerDependencies": {
"@types/react": "^16.x || ^17.x || ^18.x || ^19.x",
"@types/react-dom": "^16.x || ^17.x || ^18.x || ^19.x",
"@uswds/uswds": "^3.7.1",
"focus-trap-react": "^10.2.3",
"react": "^16.x || ^17.x || ^18.x",
"react-dom": "^16.x || ^17.x || ^18.x"
"react": "^16.x || ^17.x || ^18.x || ^19.x",
"react-dom": "^16.x || ^17.x || ^18.x || ^19.x"
},
"devDependencies": {
"@babel/core": "^7.23.9",
"@eslint/compat": "^1.2.7",
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.22.0",
"@laynezh/vite-plugin-lib-assets": "^0.5.14",
"@storybook/addon-a11y": "^8.0.4",
"@storybook/addon-essentials": "^8.0.4",
"@storybook/addon-interactions": "^8.0.4",
"@storybook/addon-links": "^8.0.4",
"@storybook/addon-mdx-gfm": "^8.0.4",
"@storybook/addons": "^7.6.10",
"@storybook/blocks": "^8.0.0",
"@storybook/manager-api": "^8.0.4",
"@storybook/react": "^8.0.4",
"@storybook/react-vite": "^8.0.4",
"@storybook/test": "^8.0.4",
"@storybook/theming": "^8.0.4",
"@storybook/addon-a11y": "^8.6.4",
"@storybook/addon-essentials": "^8.6.4",
"@storybook/addon-interactions": "^8.6.4",
"@storybook/addon-links": "^8.6.4",
"@storybook/addon-mdx-gfm": "^8.6.4",
"@storybook/blocks": "^8.6.4",
"@storybook/manager-api": "^8.6.4",
"@storybook/react": "^8.6.4",
"@storybook/react-vite": "^8.6.4",
"@storybook/test": "^8.6.4",
"@storybook/theming": "^8.6.4",
"@testing-library/dom": "^9.0.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.1.2",
"@testing-library/react": "^16.2.0",
"@testing-library/user-event": "^14.0.4",
"@types/react": "^18.2.48",
"@types/react-dom": "^18.2.18",
"@types/react-test-renderer": "^18.0.7",
"@types/react": "^19.0.10",
"@types/react-dom": "^19.0.4",
"@typescript-eslint/eslint-plugin": "^8.26.1",
"@typescript-eslint/parser": "^8.26.1",
"@uswds/uswds": "3.7.1",
Expand All @@ -125,18 +125,15 @@
"husky": "^9.0.10",
"jsdom": "^24.0.0",
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-test-renderer": "^18.2.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 praise: ‏Thank you for this cleanup!

"react": "^19.0.0",
"react-dom": "^19.0.0",
"sass": "^1.26.0",
"storybook": "^8.0.4",
"stylelint": "^16.2.1",
"storybook": "^8.6.4",
"stylelint": "^16.12.0",
"stylelint-config-css-modules": "^4.4.0",
"stylelint-config-prettier": "^9.0.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ all style-related rules have been deprecated as of stylelint 15 so this plugin is no longer necessary. Additionally, the older version has some conflicts with the other dependencies we need to update.

"stylelint-config-recommended": "^14.0.0",
"stylelint-config-sass-guidelines": "^12.1.0",
"stylelint-config-standard-scss": "^13.0.0",
"stylelint-prettier": "^5.0.0",
"typescript": "^5.1.6",
"vite": "^5.0.12",
"vite-plugin-checker": "^0.7.0",
Expand All @@ -151,8 +148,6 @@
"json-schema": "0.4.0",
"trim": "0.0.3",
"trim-newlines": "3.0.1",
"@types/react": "18.2.48",
"@types/react-dom": "18.2.18",
"@typescript-eslint/utils": "8.26.1"
},
"packageManager": "[email protected]"
Expand Down
10 changes: 5 additions & 5 deletions src/components/Accordion/Accordion.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { type JSX } from 'react'
import { Accordion, AccordionItemProps } from './Accordion'

export default {
Expand Down Expand Up @@ -100,15 +100,15 @@ const testItems: AccordionItemProps[] = [
},
]

export const Borderless = (): React.ReactElement => (
export const Borderless = (): JSX.Element => (
<Accordion bordered={false} items={testItems} />
)

export const Bordered = (): React.ReactElement => (
export const Bordered = (): JSX.Element => (
<Accordion bordered={true} items={testItems} />
)

export const Multiselectable = (): React.ReactElement => (
export const Multiselectable = (): JSX.Element => (
<Accordion items={testItems} multiselectable={true} />
)

Expand Down Expand Up @@ -166,6 +166,6 @@ const customTestItems: AccordionItemProps[] = [
},
]

export const CustomTitles = (): React.ReactElement => (
export const CustomTitles = (): JSX.Element => (
<Accordion bordered={true} items={customTestItems} />
)
6 changes: 3 additions & 3 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react'
import React, { useState, type JSX } from 'react'
import classnames from 'classnames'

import { HeadingLevel } from '../../types/headingLevel'
Expand Down Expand Up @@ -28,7 +28,7 @@ export const AccordionItem = ({
className,
headingLevel,
handleToggle,
}: AccordionItemProps): React.ReactElement => {
}: AccordionItemProps): JSX.Element => {
const headingClasses = classnames('usa-accordion__heading', className)
const contentClasses = classnames(
'usa-accordion__content',
Expand Down Expand Up @@ -67,7 +67,7 @@ export const Accordion = ({
items,
className,
multiselectable = false,
}: AccordionProps & JSX.IntrinsicElements['div']): React.ReactElement => {
}: AccordionProps & JSX.IntrinsicElements['div']): JSX.Element => {
const [openItems, setOpenState] = useState(
items.filter((i) => !!i.expanded).map((i) => i.id)
)
Expand Down
23 changes: 12 additions & 11 deletions src/components/Alert/Alert.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { type JSX } from 'react'
import { Alert } from './Alert'

import { Button } from '../Button/Button'
Expand Down Expand Up @@ -26,31 +26,31 @@ const testText = (
</>
)

export const Success = (): React.ReactElement => (
export const Success = (): JSX.Element => (
<Alert type="success" heading="Success status" headingLevel="h4">
{testText}
</Alert>
)

export const Warning = (): React.ReactElement => (
export const Warning = (): JSX.Element => (
<Alert type="warning" heading="Warning status" headingLevel="h4">
{testText}
</Alert>
)

export const Error = (): React.ReactElement => (
export const Error = (): JSX.Element => (
<Alert type="error" heading="Error status" headingLevel="h4">
{testText}
</Alert>
)

export const Info = (): React.ReactElement => (
export const Info = (): JSX.Element => (
<Alert type="info" heading="Informative status" headingLevel="h4">
{testText}
</Alert>
)

export const Slim = (): React.ReactElement => (
export const Slim = (): JSX.Element => (
<>
<Alert type="success" headingLevel="h4" slim>
{testText}
Expand All @@ -67,7 +67,7 @@ export const Slim = (): React.ReactElement => (
</>
)

export const NoIcon = (): React.ReactElement => (
export const NoIcon = (): JSX.Element => (
<>
<Alert type="success" headingLevel="h4" noIcon>
{testText}
Expand All @@ -84,7 +84,7 @@ export const NoIcon = (): React.ReactElement => (
</>
)

export const SlimNoIcon = (): React.ReactElement => (
export const SlimNoIcon = (): JSX.Element => (
<>
<Alert type="success" headingLevel="h4" slim noIcon>
{testText}
Expand All @@ -101,15 +101,16 @@ export const SlimNoIcon = (): React.ReactElement => (
</>
)

export const HeadingLevels = (): React.ReactElement => (
export const HeadingLevels = (): JSX.Element => (
<>
<h1>Heading Level 1</h1>
<Alert type="info" heading="Heading level 2" headingLevel="h2">
{testText}
</Alert>
</>
)
export const WithCTA = (): React.ReactElement => (

export const WithCTA = (): JSX.Element => (
<Alert
type="warning"
heading="Warning status"
Expand All @@ -123,7 +124,7 @@ export const WithCTA = (): React.ReactElement => (
</Alert>
)

export const WithValidation = (): React.ReactElement => (
export const WithValidation = (): JSX.Element => (
<Alert type="info" heading="Code requirements" headingLevel="h4" validation>
<ul>
<li>Use at least one uppercase character</li>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { type JSX } from 'react'
import classnames from 'classnames'

import { HeadingLevel } from '../../types/headingLevel'
Expand Down Expand Up @@ -27,7 +27,7 @@ export const Alert = ({
className,
validation,
...props
}: AlertProps & React.HTMLAttributes<HTMLDivElement>): React.ReactElement => {
}: AlertProps & React.HTMLAttributes<HTMLDivElement>): JSX.Element => {
const classes = classnames(
'usa-alert',
{
Expand Down
24 changes: 12 additions & 12 deletions src/components/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { type JSX } from 'react'
import { Button } from './Button'

export default {
Expand All @@ -17,65 +17,65 @@ Source: https://designsystem.digital.gov/components/button/
},
}

export const DefaultButton = (): React.ReactElement => (
export const DefaultButton = (): JSX.Element => (
<Button type="button">Click Me</Button>
)

export const Secondary = (): React.ReactElement => (
export const Secondary = (): JSX.Element => (
<Button type="button" secondary>
Click Me
</Button>
)

export const AccentCool = (): React.ReactElement => (
export const AccentCool = (): JSX.Element => (
<Button type="button" accentStyle="cool">
Click Me
</Button>
)

export const AccentWarm = (): React.ReactElement => (
export const AccentWarm = (): JSX.Element => (
<Button type="button" accentStyle="warm">
Click Me
</Button>
)

export const Base = (): React.ReactElement => (
export const Base = (): JSX.Element => (
<Button type="button" base>
Click Me
</Button>
)

export const Outline = (): React.ReactElement => (
export const Outline = (): JSX.Element => (
<Button type="button" outline>
Click Me
</Button>
)

export const Inverse = (): React.ReactElement => (
export const Inverse = (): JSX.Element => (
<Button type="button" inverse>
Click Me
</Button>
)

export const Big = (): React.ReactElement => (
export const Big = (): JSX.Element => (
<Button type="button" size="big">
Click Me
</Button>
)

export const Unstyled = (): React.ReactElement => (
export const Unstyled = (): JSX.Element => (
<Button type="button" unstyled>
Click Me
</Button>
)

export const CustomClass = (): React.ReactElement => (
export const CustomClass = (): JSX.Element => (
<Button type="button" className="custom-class">
Click Me
</Button>
)

export const Disabled = (): React.ReactElement => (
export const Disabled = (): JSX.Element => (
<Button type="button" disabled>
Click Me
</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { type JSX } from 'react'
import classnames from 'classnames'

export type ButtonProps = {
Expand Down Expand Up @@ -26,7 +26,7 @@ export const Button = ({
onClick,
className,
...defaultProps
}: ButtonProps & JSX.IntrinsicElements['button']): React.ReactElement => {
}: ButtonProps & JSX.IntrinsicElements['button']): JSX.Element => {
const classes = classnames(
'usa-button',
{
Expand Down
6 changes: 3 additions & 3 deletions src/components/ButtonGroup/ButtonGroup.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { type JSX } from 'react'
import { ButtonGroup } from './ButtonGroup'
import { Button } from '../Button/Button'
import { Link } from '../Link/Link'
Expand All @@ -19,7 +19,7 @@ Source: https://designsystem.digital.gov/components/button-groups/
},
}

export const Default = (): React.ReactElement => (
export const Default = (): JSX.Element => (
<ButtonGroup type="default">
<Link href="#" className="usa-button usa-button--outline">
Back
Expand All @@ -28,7 +28,7 @@ export const Default = (): React.ReactElement => (
</ButtonGroup>
)

export const Segmented = (): React.ReactElement => (
export const Segmented = (): JSX.Element => (
<ButtonGroup type="segmented">
<Button type="button">Map</Button>
<Button type="button" outline>
Expand Down
Loading