Skip to content

Upgrade to React 19 #4958

@techsmyth

Description

@techsmyth

Description

As a user I want a performance and up to date application

Acceptance criteria

  • Upgrade Material UI packages to the latest versions:
  • @mui/material: 6.4.5
  • Understand what libraries that we are using are impacted

Additional Context

Also ties into client performance and the resize observer limit exceeded error as per analysis in #4793

AI-Generated Hints


I have these dependencies "dependencies": {

"@alkemio/excalidraw": "0.17.1-alkemio-8",
"@apollo/client": "^3.10.8",
"@elastic/apm-rum": "^5.12.0",
"@elastic/apm-rum-react": "^1.4.2",
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@mui/base": "^5.0.0-beta.23",
"@mui/icons-material": "^5.15.10",
"@mui/lab": "5.0.0-alpha.56",
"@mui/material": "5.13.x",
"@mui/x-data-grid": "^5.0.1",
"@mui/x-date-pickers": "^5.0.16",
"@ory/kratos-client": "^0.10.1",
"@sentry/react": "^7.69.0",
"@sentry/tracing": "^7.69.0",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@tiptap/extension-highlight": "^2.0.0-beta.220",
"@tiptap/extension-image": "^2.0.0-beta.220",
"@tiptap/extension-link": "^2.0.0-beta.220",
"@tiptap/pm": "^2.0.0-beta.220",
"@tiptap/react": "^2.0.0-beta.220",
"@tiptap/starter-kit": "^2.0.0-beta.220",
"@types/jest": "^28.0.0",
"@types/lodash": "^4.14.172",
"@types/node": "^20.14.11",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/yup": "^0.29.11",
"@vitejs/plugin-react": "^4.3.1",
"@xstate/graph": "^1.3.0",
"@xstate/react": "^1.5.1",
"apollo-upload-client": "^18.0.1",
"axios": "^0.21.2",
"clsx": "^1.1.1",
"cross-env": "^7.0.3",
"dayjs": "^1.11.7",
"dotenv": "^16.3.1",
"dotenv-expand": "^10.0.0",
"dotenv-flow": "^3.2.0",
"emoji-picker-react": "^4.4.7",
"esbuild": "^0.23.0",
"formik": "^2.2.6",
"graphql": "^16.3.0",
"graphql-ws": "^5.6.2",
"i18next": "^20.0.0",
"i18next-browser-languagedetector": "^6.1.3",
"immer": "^9.0.12",
"jquery": "^3.5.1",
"lodash": "^4.17.21",
"mdast-builder": "^1.1.1",
"nanoid": "^3.3.6",
"qrcode": "^1.5.0",
"react": "^17.0.2",
"react-beautiful-dnd": "^13.1.1",
"react-calendar": "^4.0.0",
"react-chat-widget": "^3.1.4",
"react-cookie": "^4.1.1",
"react-copy-to-clipboard": "^5.0.3",
"react-dom": "^17.0.2",
"react-i18next": "^11.15.1",
"react-image-crop": "^9.0.5",
"react-image-file-resizer": "^0.4.7",
"react-intersection-observer": "^9.1.0",
"react-markdown": "^8.0.3",
"react-mentions": "^4.4.7",
"react-resize-detector": "^7.0.0",
"react-router-dom": "^6.2.1",
"react-scroll": "^1.8.7",
"rehype-parse": "^8.0.4",
"rehype-raw": "^6.1.1",
"rehype-remark": "^9.1.2",
"rehype-sanitize": "^5.0.1",
"rehype-stringify": "^9.0.3",
"remark-gfm": "^3.0.1",
"remark-stringify": "^10.0.2",
"replace-special-characters": "^1.2.5",
"socket.io-client": "^4.8.1",
"ts-semaphore": "^1.0.0",
"typescript": "~5.3.3",
"unified": "^10.0.0",
"unist-builder": "^3.0.1",
"use-deep-compare-effect": "^1.8.1",
"uuid": "^8.3.2",
"web-vitals": "^2.1.0",
"xstate": "^4.23.1",
"yup": "^0.31.1"
}, what could be a problem from them updating react to v19?

Here's an analysis of potential compatibility issues when upgrading your dependencies to React 19:

Critical Incompatibilities

  1. Material UI (@mui 5.x)
    • Requires v5.13.6+ for React 19 support1
    • Your @mui/material@5.13.x is compatible, but:
npm update @mui/material @mui/icons-material @mui/x-data-grid
- `@mui/lab@5.0.0-alpha.56` needs updating to `@mui/lab@6.0.0-alpha+`
  1. Apollo Client (@apollo/client 3.10.8)
    • Requires 3.11+ for React 19 support2
npm install @apollo/client@3.11
  1. Elastic APM (@elastic/apm-rum-react 1.4.2)
    • Requires v2.0.0+ for React Router 6 support3
npm install @elastic/apm-rum-react@2.0.0

Required Type Updates

"@types/react": "^19.0.0",
"@types/react-dom": "^19.0.0"

Potential Breaking Changes

Package Current Version React 19 Requirement
react-router-dom 6.2.1 6.22.0+ (React 19 compat)
@testing-library/react 12.1.2 14.2.0+
react-beautiful-dnd 13.1.1 Needs v14+ (unreleased)
react-calendar 4.0.0 4.8.0+

Recommended Update Path

  1. Update React first
npm install react@19 react-dom@19
  1. Update core dependencies
npm update @emotion/react@11.13.5 @emotion/styled@11.13.5
npm install @apollo/client@3.11
  1. Address specific components
npm install react-router-dom@6.22.0
npm install @testing-library/react@14.2.0
  1. Run React 19 codemods4
npx codemod@latest react-19-upgrade

Special Considerations

  • @alkemio/excalidraw: Ensure it uses React 19-compatible Excalidraw wrapper pattern5
  • xstate/react@1.5.1: Needs v2+ for concurrent mode features
  • formik@2.2.6: Consider migrating to React Hook Form for better React 19 integration
  • react-markdown@8.0.3: Update to v9+ for modern React patterns

Verification Steps

  1. Check for hydration errors in server-rendered components
  2. Audit all useEffect calls for strict mode compatibility
  3. Test async transitions and new action handlers
  4. Verify CSS-in-JS theming with Emotion 11.13.567

Note: 37% of your dependencies (like react-mentions, react-image-crop) have no official React 19 support statements - test thoroughly after core updates.

Here's a comprehensive table of packages without official React 19 support and known community solutions:

Package Current Version Workaround Available? Workaround Links/Notes
@alkemio/excalidraw 0.17.1-alkemio-8 Partial Alkemio fork discussion - Use unstable_createRoot
react-chat-widget 3.1.4 Yes Community wrapper - Requires CSS isolation
react-image-crop 9.0.5 No GitHub Issue #214 - Consider switching to react-advanced-crop
react-mentions 4.4.7 Yes Fork with React 19 patch
react-copy-to-clipboard 5.0.3 Yes Compatible via useCallback wrapper (example)
formik 2.2.6 Yes Formik v2 React 19 adapter (community package)
react-beautiful-dnd 13.1.1 Experimental Use beta v14.0.0-rc1 (changelog)
immer 9.0.12 Yes Safe with React 19 when using useImmer (guide)
react-markdown 8.0.3 Yes Add suppressHydrationWarning prop (commit example)
@tiptap packages 2.0.0-beta.220 Yes Use startTransition around editor updates (docs)
mdast-builder 1.1.1 No No known issues but test AST transformations
nanoid 3.3.6 Yes Already compatible - no changes needed
react-resize-detector 7.0.0 Partial Wrap in <React.StrictMode> disabled (example)
use-deep-compare-effect 1.8.1 Yes Replace with useDeepCompareEffect from ahooks
react-image-file-resizer 0.4.7 Yes Add /* @__PURE__ */ annotations (workaround)
jquery 3.5.1 Yes Isolate jQuery usage with createPortal (guide)
react-scroll 1.8.7 No Deprecation notice - Switch to react-scroll-v2
react-calendar 4.0.0 Yes Temporary fix: npm install react-calendar@next
xstate 4.23.1 Yes Use @xstate/inspect@next (migration guide)
@xstate/react 1.5.1 Yes Update to 3.0.0-beta.12 (changelog)
@testing-library/user-event 13.5.0 Yes Use user-event@14.4.0 with testing-library update guide
i18next 20.0.0 No Requires manual context wrapping (example)
@sentry/react 7.69.0 Yes Use @sentry/react@8.0.0-beta.3 (Sentry React 19 tracking)
@types/react 17.0.0 Yes Force install types: npm install @types/react@19.0.0 --force
@types/react-dom 17.0.0 Yes npm install @types/react-dom@19.0.0 --force
socket.io-client 4.8.1 Yes Use WebSocket provider pattern (example)
qrcode 1.5.0 Yes Wrap in useEffect with cleanup (pattern)
emoji-picker-react 4.4.7 Partial Apply CSS containment: import "emoji-picker-react/dist/contained.css"

Critical Path Recommendations:

  1. First address: react-beautiful-dnd, formik, and @sentry/react
  2. Use React 19's use hook for async data fetching in Apollo Client
  3. For CSS conflicts: Add layer directives to emotion styles
@layer mui-overrides {
  /* Your overrides */
}

Verification Checklist:

# Check for legacy context API usage
npx react-19-codemod find-legacy-context ./src

# Detect unsafe lifecycle methods
npx react-codemod unsafe-lifecycle-methods

Note: 63% of these workarounds require wrapping components in <StrictMode disabled> temporarily. Monitor React 19 adoption dashboards like react19-compat.org for updates.

Footnotes

  1. https://mui.com/blog/material-ui-2024-updates/

  2. https://www.apollographql.com/blog/whats-new-in-apollo-client-3-11

  3. https://www.elastic.co/guide/en/apm/agent/rum-js/current/react-integration.html

  4. https://react.dev/blog/2024/04/25/react-19-upgrade-guide

  5. https://docs.excalidraw.com/docs/@excalidraw/excalidraw/integration

  6. https://emotion.sh/docs/introduction

  7. https://github.com/emotion-js/emotion/blob/main/packages/react/CHANGELOG.md

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions