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

[Issue #3434] React USWDS, React, Next.JS upgrade #3515

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

acouch
Copy link
Collaborator

@acouch acouch commented Jan 14, 2025

Summary

Fixes #3434

Time to review: x mins

Changes proposed

What was added, updated, or removed in this PR.

Context for reviewers

Testing instructions, background context, more in-depth details of the implementation, and anything else you'd like to call out or ask reviewers. Explain how the changes were verified.

Additional information

Screenshots, GIF demos, code examples or output to help show the changes working as expected.

@@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was autogen

import { useTranslations } from "next-intl";
import Link from "next/link";
import Image from "next/image";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated this to use the same image strategy as the Footer component because this one doesn't work in React 19/Next 15 (not sure specifically why).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is no longer used, should have been removed in #507

@@ -22,7 +21,7 @@ export type ValidationErrors = {
export default function SubscriptionForm() {
const t = useTranslations("Subscribe");

const [state, formAction] = useFormState(subscribeEmail, {
const [state, formAction] = useActionState(subscribeEmail, {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -61,7 +61,8 @@ export const createSession = async (token: string) => {
}
const expiresAt = newExpirationDate();
const session = await encrypt(token, expiresAt, clientJwtKey);
cookies().set("session", session, {
const cookie = await cookies();
Copy link
Collaborator Author

@acouch acouch Jan 14, 2025

Choose a reason for hiding this comment

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

Dynamic APIs are:

  • The params and searchParams props that get provided to pages, layouts, metadata APIs, and route handlers.
  • cookies(), draftMode(), and headers() from next/headers

In Next 15, these APIs have been made asynchronous. You can read more about this in the Next.js 15 Upgrade Guide.

from: https://nextjs.org/docs/messages/sync-dynamic-apis

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed as no longer using.

@@ -1,5 +0,0 @@
import { environment } from "src/constants/environments";
Copy link
Collaborator Author

@acouch acouch Jan 14, 2025

Choose a reason for hiding this comment

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

This no longer worked, haven't researched why it was necessary. import logoPath from "public/image/logo.png" does work for static images.

@acouch acouch force-pushed the acouch/issue-3434-uswds-react-upgrade branch from 37824de to 899b198 Compare January 14, 2025 19:39
@acouch acouch force-pushed the acouch/issue-3434-uswds-react-upgrade branch from 27d030f to ae3527a Compare January 17, 2025 13:25
@acouch
Copy link
Collaborator Author

acouch commented Jan 21, 2025

I've got tests working for upgrading to React 19 and Next.JS 15.

Currently working on:

1. Couple of unexpected CSS changes image
2. Errors in the console compiling SCSS
⚠ ./src/styles/styles.scss.webpack[javascript/auto]!=!./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[13].oneOf[11].use[2]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[13].oneOf[11].use[3]!./node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js??ruleSet[1].rules[13].oneOf[11].use[4]!./node_modules/next/dist/compiled/sass-loader/cjs.js??ruleSet[1].rules[13].oneOf[11].use[5]!./src/styles/styles.scss
Deprecation Warning on line 13, column 6 of file:///Users/partisan/workshop/grants/simpler-grants-gov2/frontend/node_modules/@uswds/uswds/packages/uswds-core/src/styles/functions/units/rem-to-user-em.scss:13:6:
Global built-in functions are deprecated and will be removed in Dart Sass 3.0.0.
Use math.unit instead.

More info and automated migrator: https://sass-lang.com/d/import

13 |   @if unit($grid-in-rem) != "rem" {

node_modules/@uswds/uswds/packages/uswds-core/src/styles/functions/units/rem-to-user-em.scss 14:7  rem-to-user-em()
node_modules/@uswds/uswds/packages/uswds-core/src/styles/mixins/helpers/at-media.scss 17:12        at-media()
node_modules/@uswds/uswds/packages/usa-display/src/styles/_usa-display.scss 7:3                    @forward
node_modules/@uswds/uswds/packages/usa-display/src/styles/_index.scss 4:1                          @forward
node_modules/@uswds/uswds/packages/usa-display/_index.scss 5:1                                     @forward
node_modules/@uswds/uswds/packages/uswds-typography/_index.scss 5:1                                @forward
node_modules/@uswds/uswds/packages/uswds/_index.scss 13:1                                          @forward
src/styles/styles.scss 2:1                                                                         root stylesheet
3. Better documenting PR / changes
4. Storybook works but could possibly get it working with the pages image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade USWDS React library to React 19
1 participant