Skip to content

chore: upgrade React 17 to React 18 - #2172

Merged
jsers merged 3 commits into
mainfrom
chore-upgrade-react-18
Jul 23, 2026
Merged

chore: upgrade React 17 to React 18#2172
jsers merged 3 commits into
mainfrom
chore-upgrade-react-18

Conversation

@jsers

@jsers jsers commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator
  • Migrate ReactDOM.render to createRoot API
  • Remove deprecated componentWillMount lifecycle
  • Update react, react-dom, @types/react, @types/react-dom deps

Summary by CodeRabbit

  • New Features
    • Upgraded the application to React 18 for improved rendering and lifecycle handling.
  • Bug Fixes
    • Improved modal and dynamic chart-element cleanup.
    • Ensured query history and historical values display consistently as text.
    • Improved error message handling in data explorers.
    • Updated task output pages for reliable initialization and consistent light styling.
  • Refactor
    • Improved compatibility across forms, drag-and-drop controls, popovers, and input components.

- Migrate ReactDOM.render to createRoot API
- Remove deprecated componentWillMount lifecycle
- Update react, react-dom, @types/react, @types/react-dom deps
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f2584ae-96ca-4f43-a32c-5110084dd663

📥 Commits

Reviewing files that changed from the base of the PR and between eb8367c and f34a8bb.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (26)
  • package.json
  • src/components/ModalHOC.tsx
  • src/main.tsx
  • src/pages/dashboard/Components/ModalHOC.tsx
  • src/pages/dashboard/Renderer/Renderer/TimeSeriesNG/Main.tsx
  • src/pages/embeddedProduct/pages/List/index.tsx
  • src/pages/explorer/Elasticsearch/QueryBuilder.tsx
  • src/pages/explorer/Loki/component/context/index.tsx
  • src/pages/explorer/Loki/index.tsx
  • src/pages/hosts/pages/List/OperationModal.tsx
  • src/pages/log/IndexPatterns/index.tsx
  • src/pages/logExplorer/components/LogsViewer/components/LogFieldValue/Token.tsx
  • src/pages/targets/index.tsx
  • src/pages/taskOutput/host.jsx
  • src/pages/taskOutput/index.jsx
  • src/pages/user/component/businessForm/index.tsx
  • src/pages/user/component/passwordForm/index.tsx
  • src/pages/user/component/teamForm/index.tsx
  • src/pages/user/component/userForm/index.tsx
  • src/plugins/clickHouse/Explorer/Table.tsx
  • src/plugins/doris/Explorer/Query/index.tsx
  • src/plugins/doris/ExplorerNG/components/QueryInputAddonAfter.tsx
  • src/plugins/elasticsearch/ExplorerNG/components/QueryInputAddonAfter.tsx
  • src/plugins/mysql/Explorer/Table.tsx
  • src/plugins/pgsql/Explorer/Table.tsx
  • src/types/react18-fixes.d.ts

📝 Walkthrough

Walkthrough

React was upgraded from version 17 to 18, application and modal mounting now use createRoot, chart-injected React trees track and unmount roots, and related TypeScript compatibility, lifecycle, rendering, and callback typings were updated.

Changes

React 18 migration

Layer / File(s) Summary
React 18 dependencies and type compatibility
package.json, src/types/react18-fixes.d.ts
React packages and type definitions were upgraded, with third-party module augmentations added for React 18 JSX compatibility.
Application and modal root mounting
src/main.tsx, src/components/ModalHOC.tsx, src/pages/dashboard/Components/ModalHOC.tsx
The application and dynamically created modals use createRoot, root.render, and root.unmount.
uPlot external DOM root lifecycle
src/pages/dashboard/Renderer/Renderer/TimeSeriesNG/Main.tsx
Tooltip and annotation render targets reuse cached roots, which are unmounted during chart deletion.
React 18 callback and ref typing adjustments
src/pages/embeddedProduct/pages/List/index.tsx, src/pages/log/IndexPatterns/index.tsx, src/pages/logExplorer/.../Token.tsx, src/pages/user/component/*/index.tsx, src/plugins/*/Explorer/Table.tsx
Forwarded refs, sortable handles, popup callbacks, and tooltip callbacks received updated TypeScript signatures.
Rendering and mount-time compatibility fixes
src/pages/explorer/Elasticsearch/QueryBuilder.tsx, src/pages/explorer/Loki/..., src/pages/hosts/pages/List/OperationModal.tsx, src/pages/targets/index.tsx, src/pages/taskOutput/*, src/plugins/doris/..., src/plugins/elasticsearch/...
Values are string-coerced, conditional rendering uses null fallbacks, errors are typed, and task output initialization runs in componentDidMount.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BrowserDOM
  participant ReactRoot
  participant AppTree
  BrowserDOM->>ReactRoot: createRoot(root container)
  ReactRoot->>AppTree: root.render(I18nextProvider and App)
  AppTree->>BrowserDOM: render application UI
  BrowserDOM->>ReactRoot: root.unmount()
Loading

Suggested reviewers: guguji5

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore-upgrade-react-18

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
package.json

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jsers
jsers marked this pull request as ready for review July 23, 2026 07:06
Copilot AI review requested due to automatic review settings July 23, 2026 07:06
@jsers
jsers merged commit 8663c1f into main Jul 23, 2026
1 of 2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the app from React 17 to React 18, updating ReactDOM rendering APIs and addressing stricter React 18 / TypeScript typings across the codebase (including targeted third‑party type augmentations and JSX typing fixes).

Changes:

  • Upgrade react, react-dom, @types/react, and @types/react-dom dependencies.
  • Migrate ReactDOM.render / unmountComponentAtNode usage to the React 18 createRoot API.
  • Apply React 18 TypeScript compatibility adjustments (type augmentations, safer JSX rendering via String(...), and children typing workarounds).

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/types/react18-fixes.d.ts Adds module augmentations to smooth React 18 typing friction with third-party libraries.
src/plugins/pgsql/Explorer/Table.tsx React 18 typing adjustments around resizable header tooltip rendering.
src/plugins/mysql/Explorer/Table.tsx React 18 typing adjustments around resizable header tooltip rendering.
src/plugins/clickHouse/Explorer/Table.tsx React 18 typing adjustments around resizable header tooltip rendering.
src/plugins/elasticsearch/ExplorerNG/components/QueryInputAddonAfter.tsx Ensures displayed historical record values are renderable under stricter typings.
src/plugins/doris/ExplorerNG/components/QueryInputAddonAfter.tsx Ensures displayed historical record values are renderable under stricter typings.
src/plugins/doris/Explorer/Query/index.tsx Ensures displayed historical record values are renderable under stricter typings.
src/pages/explorer/Elasticsearch/QueryBuilder.tsx Ensures displayed query metadata values are renderable under stricter typings.
src/pages/explorer/Loki/index.tsx React 18 typing adjustments for error display.
src/pages/explorer/Loki/component/context/index.tsx React 18 typing adjustments for error display.
src/pages/dashboard/Renderer/Renderer/TimeSeriesNG/Main.tsx Migrates embedded React rendering inside uPlot overlays to createRoot.
src/pages/dashboard/Components/ModalHOC.tsx Migrates modal HOC rendering/unmounting to createRoot.
src/components/ModalHOC.tsx Migrates modal HOC rendering/unmounting to createRoot.
src/main.tsx Migrates application bootstrap rendering to createRoot.
src/pages/user/component/userForm/index.tsx Adjusts forwardRef typing for React 18 / TS strictness.
src/pages/user/component/teamForm/index.tsx Adjusts forwardRef typing for React 18 / TS strictness.
src/pages/user/component/passwordForm/index.tsx Adjusts forwardRef typing for React 18 / TS strictness.
src/pages/user/component/businessForm/index.tsx Adjusts forwardRef typing for React 18 / TS strictness.
src/pages/targets/index.tsx JSX children typing workaround via fragment wrapping and explicit nullability.
src/pages/hosts/pages/List/OperationModal.tsx JSX children typing workaround via fragment wrapping and explicit nullability.
src/pages/logExplorer/components/LogsViewer/components/LogFieldValue/Token.tsx Tightens popup container callback typing/casting under React 18 typings.
src/pages/log/IndexPatterns/index.tsx Improves generic typing for SortableHandle with React 18 typings.
src/pages/embeddedProduct/pages/List/index.tsx Improves generic typing for SortableHandle with React 18 typings.
src/pages/taskOutput/index.jsx Removes deprecated lifecycle usage as part of React 18 migration.
src/pages/taskOutput/host.jsx Removes deprecated lifecycle usage as part of React 18 migration.
package.json Bumps React + type dependencies and removes obsolete overrides.

Comment on lines 52 to 55
const { components, resizableColumns, tableWidth, resetColumns } = useAntdResizableHeader({
columns: useMemo(() => columns, [columnsKeys]),
tooltipRender: (props) => <Tooltip {...props} />,
tooltipRender: (props: any) => <Tooltip {...props} />,
defaultWidth: 150,
Comment on lines 53 to 56
const { components, resizableColumns, tableWidth, resetColumns } = useAntdResizableHeader({
columns: useMemo(() => columns, [columnsKeys]),
tooltipRender: (props) => <Tooltip {...props} />,
tooltipRender: (props: any) => <Tooltip {...props} />,
defaultWidth: 150,
Comment on lines 51 to 54
const { components, resizableColumns, tableWidth, resetColumns } = useAntdResizableHeader({
columns: useMemo(() => columns, [columnsKeys]),
tooltipRender: (props) => <Tooltip {...props} />,
tooltipRender: (props: any) => <Tooltip {...props} />,
defaultWidth: 150,
}
} catch (err) {
message.error(err);
message.error(err as string);
setData(_.concat(parseResponse(res2.result || []).dataRows, parseResponse(res1.result || []).dataRows));
} catch (err) {
message.error(err);
message.error(err as string);

const { Option } = Select;
const UserForm = React.forwardRef<ReactNode, UserAndPasswordFormProps>((props, ref) => {
const UserForm = React.forwardRef<any, UserAndPasswordFormProps>((props, ref) => {
import { CommonStateContext } from '@/App';

const TeamForm = React.forwardRef<ReactNode, TeamProps>((props, ref) => {
const TeamForm = React.forwardRef<any, TeamProps>((props, ref) => {
import { UserAndPasswordFormProps } from '@/store/manageInterface';
import { useTranslation } from 'react-i18next';
const PasswordForm = React.forwardRef<ReactNode, UserAndPasswordFormProps>((props, ref) => {
const PasswordForm = React.forwardRef<any, UserAndPasswordFormProps>((props, ref) => {

const { Option } = Select;
const TeamForm = React.forwardRef<ReactNode, TeamProps>((props, ref) => {
const TeamForm = React.forwardRef<any, TeamProps>((props, ref) => {
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