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

Better support for React 19 #3268

Merged
merged 3 commits into from
Oct 24, 2024
Merged

Better support for React 19 #3268

merged 3 commits into from
Oct 24, 2024

Conversation

HalvorHaugan
Copy link
Contributor

@HalvorHaugan HalvorHaugan commented Oct 22, 2024

Description

  1. Issue with react-day-picker: https://nav-it.slack.com/archives/C7NE7A8UF/p1729591976799829
    Upgrading to 8.10.1 seems to fix it. I didn't get the same error message as reported in Slack though.

  2. Issue with Slot: https://nav-it.slack.com/archives/C7NE7A8UF/p1729598429628389?thread_ts=1729591976.799829&cid=C7NE7A8UF
    It's just a warning, but can be annoying. Fixed by using ref from props when possible.
    https://react.dev/blog/2024/04/25/react-19-upgrade-guide#deprecated-element-ref

You can recreate by either using the next-appdir example instance, or by upgrading to React in the root package.json:

    "react": "rc",
    "react-dom": "rc",

There might be other issues that I don't know about, but this will at least fix the immediate issues reported in Slack.

Component Checklist 📝

  • JSDoc
  • Examples
  • Documentation
  • Storybook
  • Style mappings (@navikt/core/css/config/_mappings.js)
  • Component tokens (@navikt/core/css/tokens.json)
  • CSS class deprecations (@navikt/aksel-stylelint/src/deprecations.ts)
  • Exports (@navikt/core/react/src/index.ts and @navikt/core/react/package.json)
  • New component? CSS import (@navikt/core/css/index.css)
  • Breaking change? Update migration guide. Consider codemod.
  • Changeset (Format: <Component>: <gitmoji?> <Text>. E.g. "Button: ✨ Add feature xyz.")

Copy link

changeset-bot bot commented Oct 22, 2024

🦋 Changeset detected

Latest commit: ef87bfd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@navikt/ds-react Patch
@navikt/ds-css Patch
@navikt/ds-tokens Patch
@navikt/ds-tailwind Patch
@navikt/aksel-icons Patch
@navikt/aksel Patch
@navikt/aksel-stylelint Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 22, 2024

Storybook demo

06590c887 | 91 komponenter | 144 stories

@HalvorHaugan HalvorHaugan changed the title Date/MonthPicker: Upgrade react-day-picker to fix issue with Nextjs 15 Better support for React 19 Oct 22, 2024
"@navikt/ds-react": patch
---

Avoid warning about element.ref in React 19
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since Slot is an internal component, I don't think it's relevant to mention it. We could mention every component that uses it, but then I think the text would become too long 😅

"@navikt/ds-react": patch
---

Date/MonthPicker: Upgrade react-day-picker to fix issue with React 19
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ref. my previous comment, perhaps we should not mention react-day-picker either? Maybe just write "Fix issue with React 19"?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it's a transitive dependency, and consumers will be able to see it in their node_modules, but they should probably also not care what we use to build stuff under the hood? 🤔. it's just a patch, and I guess most will probably filter out release notes on the patch level anyways?. I say just keep it as this, it's at least transparent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried just doing children.props.ref || (children as any).ref first, but it didn't work properly.

@@ -19,7 +19,8 @@
],
"paths": {
"@/*": ["./src/*"]
}
},
"target": "ES2017"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nextjs added this automatically 🤷‍♂️

@JulianNymark JulianNymark self-requested a review October 23, 2024 11:57
"@next/bundle-analyzer": "^14.1.0",
"next": "14.2.12",
"@next/bundle-analyzer": "^15.0.0",
"next": "15.0.0",
"react": "^18",
Copy link
Contributor

Choose a reason for hiding this comment

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

should we upgrade to react 19 for the example nextjs project as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we might wanted to wait until it's officially released, but I don't have any strong opinions about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

the app dir actually requires react 19 (and you have automatically been using a canary version of it since next 13 if you've been app-dirring)

Copy link
Contributor

@JulianNymark JulianNymark left a comment

Choose a reason for hiding this comment

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

tested and works (not getting any errors in console client or server side) 🚀

@HalvorHaugan HalvorHaugan merged commit fdc3244 into main Oct 24, 2024
4 checks passed
@HalvorHaugan HalvorHaugan deleted the picker-next15-fix branch October 24, 2024 07:07
@github-actions github-actions bot mentioned this pull request Oct 24, 2024
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.

3 participants