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

JNG-6102 React 19 #504

Merged
merged 1 commit into from
Jan 10, 2025
Merged

JNG-6102 React 19 #504

merged 1 commit into from
Jan 10, 2025

Conversation

noherczeg
Copy link
Contributor

@noherczeg noherczeg commented Jan 10, 2025

StoryJNG-6102 Upgrade to React 19

Copy link

coderabbitai bot commented Jan 10, 2025

Walkthrough

This pull request encompasses a comprehensive update across multiple files in a React project, focusing on dependency upgrades, type assertions, and minor component refactoring. The changes include updating package dependencies to newer versions, modifying type handling in table components, simplifying the drawer header component, and configuring the Vite build process with a new React compiler plugin. The modifications aim to improve type safety, update library versions, and potentially enhance React component compilation.

Changes

File Change Summary
package.json (dependencies) - Upgraded multiple MUI, React, and other library versions
- Added new @mui/x-license dependency
package.json (dev-dependencies) - Added babel-plugin-react-compiler
- Updated vite and vitest versions
EagerTable.tsx & LazyTable.tsx - Modified apiRef type assertions
- Updated overflow styling
DrawerHeader.tsx - Removed DrawerHeaderStyled component
- Simplified styling using Box component
main.tsx - Updated MUI license import path
vite.config.ts - Added React compiler plugin configuration

Poem

🐰 Hop, hop, dependencies dance!
Versions leap with each new chance
React compiler joins the race
MUI styling finds its place
Code evolves with bunny grace! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
judo-ui-react/src/main/resources/actor/src/layout/Drawer/DrawerHeader.tsx.hbs (1)

Line range hint 22-37: Consider extracting complex sx styles

While the transition to using the sx prop is good, the complex conditional styling could be more maintainable if extracted into a separate constant or helper function.

Consider refactoring like this:

const getDrawerHeaderStyles = (theme: Theme, open: boolean, isHorizontal: boolean) => ({
  ...theme.mixins.toolbar,
  display: 'flex',
  alignItems: 'center',
  justifyContent: open ? 'flex-start' : 'center',
  minHeight: isHorizontal ? 'unset' : '60px',
  width: isHorizontal ? { xs: '100%', lg: '424px' } : 'inherit',
  paddingTop: isHorizontal ? { xs: '10px', lg: '0' } : '8px',
  paddingBottom: isHorizontal ? { xs: '18px', lg: '0' } : '8px',
  paddingLeft: isHorizontal ? { xs: '24px', lg: '0' } : open ? '24px' : 0,
  paddingRight: isHorizontal ? { xs: '24px', lg: '0' } : open ? '24px' : 0,
});

// Usage in component:
<Box sx={getDrawerHeaderStyles(theme, open, isHorizontal)}>

This would improve readability and make the styles more reusable if needed.

judo-ui-react/src/main/resources/actor/vite.config.ts.hbs (1)

Line range hint 13-28: Review chunk splitting strategy

The manual chunk configuration looks good but consider:

  1. Impact on initial load time
  2. Cache invalidation strategy
  3. Common dependencies across chunks

Consider analyzing bundle sizes after the React 19 and MUI 6 upgrades to optimize the splitting strategy.

judo-ui-react/src/main/resources/actor/src/components/table/EagerTable.tsx.hbs (1)

Line range hint 288-292: Consider using a type-safe approach for apiRef casting.

The current type assertion (apiRef as unknown as any) bypasses TypeScript's type checking. While this works, it might hide potential type-related issues.

Consider:

  1. Using proper types from @mui/x-data-grid-pro
  2. Creating a type-safe wrapper for the grid API
judo-ui-react/src/main/resources/actor/src/components/table/LazyTable.tsx.hbs (1)

Line range hint 319-324: Maintain consistency with EagerTable implementation.

The changes in LazyTable mirror those in EagerTable, which is good for consistency. However, both components could benefit from a more type-safe approach to API reference handling.

Consider extracting the common table functionality into a shared hook or utility to reduce code duplication and ensure consistent behavior.

Also applies to: 632-639

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0df332e and 7465893.

⛔ Files ignored due to path filters (1)
  • judo-ui-react/src/main/resources/actor/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • judo-ui-react-itest/ActionGroupTestPro/action_group_test_pro__god/src/test/resources/snapshots/frontend-react/src/components/table/EagerTable.tsx.snapshot (3 hunks)
  • judo-ui-react-itest/ActionGroupTestPro/action_group_test_pro__god/src/test/resources/snapshots/frontend-react/src/components/table/LazyTable.tsx.snapshot (3 hunks)
  • judo-ui-react/src/main/resources/actor/package.json.dependencies.fragment.hbs (1 hunks)
  • judo-ui-react/src/main/resources/actor/package.json.dev-dependencies.fragment.hbs (1 hunks)
  • judo-ui-react/src/main/resources/actor/src/components/table/EagerTable.tsx.hbs (3 hunks)
  • judo-ui-react/src/main/resources/actor/src/components/table/LazyTable.tsx.hbs (3 hunks)
  • judo-ui-react/src/main/resources/actor/src/layout/Drawer/DrawerHeader.tsx.hbs (3 hunks)
  • judo-ui-react/src/main/resources/actor/src/main.tsx.hbs (1 hunks)
  • judo-ui-react/src/main/resources/actor/vite.config.ts.hbs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • judo-ui-react-itest/ActionGroupTestPro/action_group_test_pro__god/src/test/resources/snapshots/frontend-react/src/components/table/LazyTable.tsx.snapshot
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ⏳ Build, test and deploy artifacts
🔇 Additional comments (13)
judo-ui-react/src/main/resources/actor/src/layout/Drawer/DrawerHeader.tsx.hbs (3)

4-7: LGTM! Clean import organization

The import restructuring aligns well with the removal of styled-components, maintaining a clean and organized import structure.


Line range hint 13-21: LGTM! Component logic is well-structured

The component maintains clean hook usage and proper conditional logic for layout handling.


Line range hint 1-39: Verify MUI component compatibility with React 19

While the component looks compatible with React 19, we should verify the compatibility of the used MUI components.

✅ Verification successful

MUI components are compatible with React 19

The used MUI components (Box, useTheme, useMediaQuery) are from MUI v6.3.1, which is specifically designed for React 19 compatibility. All previously reported React 19 compatibility issues have been resolved in the current version.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check package.json for MUI versions and any React 19 compatibility notes
rg -A 5 '"@mui/material":\s*"[^"]*"' package.json
rg -A 5 '"react":\s*"[^"]*"' package.json

# Check for any React 19 related issues in MUI's issue tracker
gh api graphql -f query='
{
  search(query: "repo:mui/material-ui react 19 compatibility", type: ISSUE, first: 5) {
    nodes {
      ... on Issue {
        title
        url
        state
      }
    }
  }
}
'

Length of output: 873


Script:

#!/bin/bash
# Find package.json files
fd package.json

# Once found, check their content for MUI and React versions
fd package.json --exec cat {} \; 

Length of output: 2954

judo-ui-react/src/main/resources/actor/package.json.dependencies.fragment.hbs (4)

5-13: Review MUI v6 beta compatibility

The upgrade to MUI v6 beta versions (@mui/lab beta.22, @mui/material 6.3.1) includes breaking changes:

  • New styling system
  • Component API changes
  • Theme structure updates

Consider:

  1. Deferring the MUI v6 upgrade until stable release
  2. Creating a comprehensive migration plan
  3. Adding detailed testing for MUI components

1-35: Verify peer dependency compatibility

Multiple major version updates (React 19, MUI 6, React Router 7) require careful verification of peer dependency compatibility.

Run this script to check for potential peer dependency conflicts:

✅ Verification successful

Peer dependencies are compatible

All major version updates (React 19, MUI 6, React Router 7) have compatible peer dependency requirements. No conflicts detected in the dependency chain.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Extract peer dependency requirements
for pkg in @mui/material @mui/lab react-router-dom react-oidc-context react-hotkeys-hook
do
  echo "Checking $pkg..."
  curl -s "https://registry.npmjs.org/$pkg/latest" | jq '.peerDependencies'
done

Length of output: 1871


25-25: Verify React 19 compatibility with existing codebase

React 19.0.0 is a major version upgrade that introduces breaking changes. Key areas to verify:

  • Use of deprecated lifecycle methods
  • Changes in event handling
  • Effects cleanup
  • Automatic batching behavior

Run this script to identify potential compatibility issues:

Also applies to: 27-27

✅ Verification successful

React 19 upgrade appears safe to proceed

The codebase follows modern React patterns and best practices:

  • Uses createRoot API
  • Implements StrictMode
  • Has proper error boundaries and Suspense
  • No deprecated lifecycle methods found
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for deprecated React patterns and lifecycle methods
ast-grep --pattern 'componentWillMount|componentWillReceiveProps|componentWillUpdate'

# Check for common React patterns that might need updates
rg -l 'useEffect|useState|createRef|forwardRef'

Length of output: 7293


Script:

#!/bin/bash
# Check for React 19 specific patterns and features
echo "=== Checking for Strict Mode usage ==="
rg -l "StrictMode"

echo -e "\n=== Checking for Suspense and Error Boundary usage ==="
rg -l "Suspense|ErrorBoundary"

echo -e "\n=== Checking for concurrent mode features ==="
rg -l "useTransition|useDeferredValue|startTransition"

echo -e "\n=== Checking for root creation pattern ==="
rg -A 5 "createRoot|render" "src/index|src/main"

Length of output: 3468


Script:

#!/bin/bash
# Check root creation pattern with correct path
echo "=== Checking root creation in main.tsx ==="
rg -A 5 "createRoot|render" "judo-ui-react/src/main/resources/actor/src/main.tsx.hbs"

echo -e "\n=== Checking React.lazy usage ==="
rg "React\.lazy" "judo-ui-react/src/main/resources/actor/src/"

Length of output: 1029


33-34: Verify React Router v7 migration requirements

React Router v7 introduces breaking changes in routing behavior and APIs.

Run this script to identify potential migration needs:

✅ Verification successful

React Router v7 migration verification completed

The codebase already follows modern React Router patterns that are compatible with v7. The current implementation uses createHashRouter, RouterProvider, and the useNavigate hook in a way that aligns with v7's requirements. No deprecated v6 patterns that would break in v7 were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for React Router v6 patterns that need updates
rg -l 'useNavigate|useLocation|useParams|Routes|Route'

Length of output: 2545


Script:

#!/bin/bash
# Check Route and Routes component usage patterns
echo "=== Checking Route configurations ==="
rg -A 2 '<Route' --type tsx

echo -e "\n=== Checking useNavigate usage ==="
rg -A 2 'useNavigate' --type tsx

echo -e "\n=== Checking navigation calls ==="
rg -A 2 'navigate\(' --type tsx

Length of output: 433


Script:

#!/bin/bash
# Check Route configurations and navigation patterns
echo "=== Checking Route element prop usage ==="
rg -A 2 '<Route.*element='

echo -e "\n=== Checking useNavigate and navigation patterns ==="
rg -A 2 'useNavigate|navigate\('

echo -e "\n=== Checking other v6 specific patterns ==="
rg -A 2 'createBrowserRouter|RouterProvider|loader:|action:'

Length of output: 51739

judo-ui-react/src/main/resources/actor/package.json.dev-dependencies.fragment.hbs (2)

9-9: Review stability of babel-plugin-react-compiler beta

Using a beta version of babel-plugin-react-compiler in production may lead to instability.

Consider:

  1. Checking the plugin's GitHub issues for known problems
  2. Testing the build process thoroughly
  3. Having a rollback plan

11-12: Verify Vite 6 and Vitest compatibility

Major version upgrades of build tools require careful verification:

  • Vite 6.0.7 (major upgrade)
  • Vitest 2.1.8 (major upgrade)

Run this script to check for potential build configuration issues:

✅ Verification successful

Vite 6 and Vitest 2 upgrade appears safe

The codebase uses standard, stable APIs that are compatible with both Vite 6 and Vitest 2. No deprecated features or breaking changes were found in the configuration or test files.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Vite-specific configuration
rg -l 'defineConfig|loadEnv|createServer|build.rollupOptions'

Length of output: 121


Script:

#!/bin/bash
# Check Vite config content
cat judo-ui-react/src/main/resources/actor/vite.config.ts.hbs

# Search for Vitest configuration and test files
rg -l "vitest" --type ts --type js

Length of output: 1356


Script:

#!/bin/bash
# Check content of a test file for Vitest patterns
cat "judo-ui-react/src/main/resources/actor/src/utilities/table.test.ts"

# Look for Vitest config files
fd -e ts -e js vitest.config

Length of output: 3699

judo-ui-react/src/main/resources/actor/vite.config.ts.hbs (1)

29-35: Verify React compiler plugin configuration

The babel-plugin-react-compiler configuration needs verification:

  1. Empty options object might need configuration
  2. Plugin order might affect compilation

Consider documenting the compiler plugin's purpose and configuration options.

judo-ui-react/src/main/resources/actor/src/components/table/EagerTable.tsx.hbs (1)

476-485: Verify the overflow style change impact.

The overflow property has been moved from a comment to an active style. Ensure this doesn't affect table behavior in different scenarios.

judo-ui-react-itest/ActionGroupTestPro/action_group_test_pro__god/src/test/resources/snapshots/frontend-react/src/components/table/EagerTable.tsx.snapshot (2)

295-295: Review type assertions carefully

The type assertions apiRef as unknown as any bypass TypeScript's type checking system. While this might be necessary for compatibility with the MUI Data Grid API, it could mask potential type-related issues.

Let's verify if there's a better way to type this:

Also applies to: 480-480

✅ Verification successful

Type assertions are consistently implemented

The apiRef as unknown as any type assertions are used consistently across both EagerTable and LazyTable components, appearing in both source templates and snapshots. This pattern appears to be an intentional design choice for handling MUI DataGrid's API compatibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other usages of gridColumnDefinitionsSelector to see if there's a better typing pattern
ast-grep --pattern 'gridColumnDefinitionsSelector($_)'

# Search for other apiRef type assertions to ensure consistency
rg 'apiRef as unknown as any'

Length of output: 1592


485-485: Verify overflow behavior impact

Setting overflow: 'hidden' on the grid could affect how content is displayed in cells, especially with dynamic content or when using features like cell editing or tooltips.

Let's check for potential overflow-related issues:

✅ Verification successful

Overflow style is correctly implemented

The overflow: 'hidden' on the grid container is a standard practice for CSS Grid layouts and is consistently implemented across both EagerTable and LazyTable components. This style ensures proper grid boundaries without affecting individual cell content behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for related overflow styles or issues
rg -A 2 'overflow:.*hidden' 

# Look for any existing overflow-related comments or issues
rg -i 'overflow|scroll' 

Length of output: 18402

@noherczeg noherczeg merged commit ce02a39 into develop Jan 10, 2025
3 checks passed
@noherczeg noherczeg deleted the feature/JNG-6102-react-19 branch January 10, 2025 00:20
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.

2 participants