-
Notifications
You must be signed in to change notification settings - Fork 668
CONSOLE-4402: React 18 upgrade - phase 1 (WIP) #14869
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
base: main
Are you sure you want to change the base?
Conversation
c985555 to
b757ff6
Compare
|
can we check the conflicts with base branch |
8b94bf1 to
a64eb5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/packages/console-app/src/hooks/usePluginRoutes.tsx (1)
12-32: Verify cache invalidation logic aligns with useMemo dependencies.The caching approach is sound for preventing component recreation on re-renders. However, there's a subtle inconsistency:
- The
useMemodependency array includes bothuidandcomponent(line 29)- The cache lookup and storage use only
uidas the key (lines 19-28)If the
componentfunction reference changes whileuidremains the same,useMemowill re-execute but still return the cached component created with the oldcomponentfunction. This inconsistency could lead to stale components being rendered if extensions support hot-reloading or dynamic updates.Recommendations:
- If
componentreferences are stable for a givenuid(typical for static plugin systems), removecomponentfrom the dependency array:}, [uid]);- If components can change, either use a composite cache key or invalidate the cache entry when detecting a change
In practice, this is likely not an issue if extensions are loaded once at startup with stable references.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
frontend/packages/console-app/src/hooks/usePluginRoutes.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/console-app/src/hooks/usePluginRoutes.tsx
🔇 Additional comments (2)
frontend/packages/console-app/src/hooks/usePluginRoutes.tsx (2)
1-1: LGTM!Adding
ComponentTypeto the imports is necessary for the type annotation of the lazy component cache.
39-41: LGTM!Correctly adds missing dependencies (
extension.properties.perspective,path,setActivePerspective) to theuseEffectdependency array, ensuring the effect runs when these values change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/packages/console-app/src/hooks/usePluginRoutes.tsx (1)
12-31: Cache invalidation doesn't account forcomponentprop changes.The
useMemodependency array includescomponent, but the cache key is onlyuid. Ifcomponentchanges whileuidremains the same, the stale cached lazy component is returned because the cache-hit path doesn't verify thecomponentreference.Additionally,
lazyComponentCache.get(uid)returnsT | undefined, soLazyComponentmay be typed as potentially undefined.🔎 Proposed fix using a composite cache key or non-null assertion
Option 1: Use non-null assertion since the logic guarantees existence:
- return lazyComponentCache.get(uid); - }, [uid, component]); + return lazyComponentCache.get(uid)!; + }, [uid, component]);Option 2: If
componentcan realistically change, consider keying by bothuidand a stable component identifier, or clear the cache entry when the component changes:const LazyComponent = useMemo(() => { - if (!lazyComponentCache.has(uid)) { + const cached = lazyComponentCache.get(uid); + // Clear cache if component reference changed (rare but possible) + if (cached === undefined) { lazyComponentCache.set( uid, lazy(async () => { const Component = await component(); return { default: Component }; }), ); } - return lazyComponentCache.get(uid); + return lazyComponentCache.get(uid)!; }, [uid, component]);If extensions are guaranteed to have stable
componentprops, document this assumption and removecomponentfrom the dependency array to avoid confusion.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
frontend/packages/console-app/src/hooks/usePluginRoutes.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**
⚙️ CodeRabbit configuration file
-Focus on major issues impacting performance, readability, maintainability and security. Avoid nitpicks and avoid verbosity.
Files:
frontend/packages/console-app/src/hooks/usePluginRoutes.tsx
🔇 Additional comments (2)
frontend/packages/console-app/src/hooks/usePluginRoutes.tsx (2)
1-1: LGTM!Import addition is necessary for the
lazyComponentCachetype annotation.
39-41: LGTM!Correct exhaustive dependency array for the
useEffect. All values referenced in the effect body are now properly listed.
|
@logonoff: This pull request references CONSOLE-4402 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
c9d00c1 to
733112d
Compare
- Remove children from BaseEdge component (no longer supported) - Wrap status components with PopoverStatus when displaying children - Add type check for label value in OLM descriptor - Also add missing loadError and desc props to StorageClassDropdownInnerProps 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Remove invalid placeholder prop from MenuToggle components (replaced with aria-label) - Add ts-ignore invalid icon test value These changes fix TS2322 type errors where React 18's stricter type checking was incompatible with the previous code patterns. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add children?: ReactNode to component prop types that were missing it, causing TS2339 errors in React 18. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ct 18 Replace deprecated React.Component types with React.ReactNode in: - DetailsResourceAlertContent.content - DetailsResourceLink.link return type - DetailsTabSection.section return type - useDetailsResourceLink return type React 18's stricter type checking no longer accepts the old React.Component class type where ReactNode is expected. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix various TypeScript type errors introduced by React 18's stricter typing: - DndProvider: Cast to include children prop (drag-drop-context.tsx) - ActionsMenu: Remove explicit FCC type annotation to let TypeScript infer from connect() HOC (actions-menu.tsx) - ChartVoronoiContainer: Wrap getLabel in arrow function to match expected signature (area.tsx, stack.tsx) - BarChart: Handle Date type for x-axis rendering (bar.tsx) - EditYAML: Explicitly allow loading strings (edit-yaml.tsx) - ConfigureCountModal: Cast translation result to string (configure-count-modal.tsx) - AlertmanagerConfig: Cast data-test props as TdProps (alertmanager-config.tsx) - WebhookToastContent: Fix Trans interpolation syntax (WebhookToastContent.tsx) - HelmReleaseResourcesRow.spec: Update column types to ConsoleDataViewColumn (HelmReleaseResourcesRow.spec.tsx) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
@logonoff: This pull request references CONSOLE-4402 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
The LazyDynamicRoutePage component was calling React.lazy() inside a useMemo that depended on the component prop reference. During in-app navigation, if extension references changed, this caused: 1. React.lazy() to be called again, creating a new lazy component 2. React to unmount the old component and mount the new one 3. Suspense to trigger loading state and re-resolve the async import 4. Cascading re-mounts causing 100% CPU usage and page freeze Fix: Cache lazy components by extension UID in a module-level Map. The lazy component is created once per extension and reused on subsequent renders, preventing unnecessary remounting during navigation.
|
@logonoff: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Depends on #15893, #15854, and #15875
This PR aims to bump our React dependency to 18. We will NOT be using the new
createRootmethod here, this will be done in a follow-up. Why?@types/reactquicker (namely making React.FCC redundant)createRootrender functionChanges:
react,react-dom,@types/react,@types/react-domto 18.xallowObjectInHTMLChildren-- see Cannot pass objects to<Trans>with React 18 type definitions i18next/react-i18next#1483LazyRoutePagehanging multiple pages within our app (especially in the developer perspective), like +Add, Topology