From 1cf9d4c6cb601a67d1445be2acb476c8cf0002f7 Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Sun, 29 Jun 2025 08:55:39 +0000 Subject: [PATCH] Migrate ReactDOM.render to createRoot API for React 18 - Replace ReactDOM.render() with createRoot().render() in all components - Remove unused ReactDOM imports - Update main app entry point (app/index.tsx) - Update editor components (BlockMenu, uploadPlaceholder, Notice) - Applied automated codemod for consistent migration --- app/editor/extensions/BlockMenu.tsx | 5 +++-- app/index.tsx | 5 +++-- shared/editor/lib/uploadPlaceholder.tsx | 5 +++-- shared/editor/nodes/Notice.tsx | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/editor/extensions/BlockMenu.tsx b/app/editor/extensions/BlockMenu.tsx index ead19219f2..4ead0803e7 100644 --- a/app/editor/extensions/BlockMenu.tsx +++ b/app/editor/extensions/BlockMenu.tsx @@ -1,8 +1,8 @@ +import { createRoot } from "react-dom/client"; import { action } from "mobx"; import { PlusIcon } from "outline-icons"; import { Plugin } from "prosemirror-state"; import { Decoration, DecorationSet } from "prosemirror-view"; -import ReactDOM from "react-dom"; import { WidgetProps } from "@shared/editor/lib/Extension"; import { PlaceholderPlugin } from "@shared/editor/plugins/PlaceholderPlugin"; import { findParentNode } from "@shared/editor/queries/findParentNode"; @@ -27,7 +27,8 @@ export default class BlockMenuExtension extends Suggestion { const button = document.createElement("button"); button.className = "block-menu-trigger"; button.type = "button"; - ReactDOM.render(, button); + const root = createRoot(button); + root.render(); return [ ...super.plugins, diff --git a/app/index.tsx b/app/index.tsx index ede59695e2..f593d02896 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,10 +1,10 @@ +import { createRoot } from "react-dom/client"; // eslint-disable-next-line import/no-unresolved import "vite/modulepreload-polyfill"; import { LazyMotion } from "framer-motion"; import { KBarProvider } from "kbar"; import { Provider } from "mobx-react"; import { StrictMode } from "react"; -import { render } from "react-dom"; import { HelmetProvider } from "react-helmet-async"; import { Router } from "react-router-dom"; import stores from "~/stores"; @@ -79,7 +79,8 @@ if (element) { ); - render(, element); + const root = createRoot(element); + root.render(); } window.addEventListener("load", async () => { diff --git a/shared/editor/lib/uploadPlaceholder.tsx b/shared/editor/lib/uploadPlaceholder.tsx index 3db6d99165..423ee5d23b 100644 --- a/shared/editor/lib/uploadPlaceholder.tsx +++ b/shared/editor/lib/uploadPlaceholder.tsx @@ -1,7 +1,7 @@ +import { createRoot } from "react-dom/client"; import { EditorState, Plugin } from "prosemirror-state"; import { Decoration, DecorationSet } from "prosemirror-view"; import * as React from "react"; -import ReactDOM from "react-dom"; import FileExtension from "../components/FileExtension"; import { isRemoteTransaction } from "./multiplayer"; import { recreateTransform } from "./prosemirror-recreate-transform"; @@ -100,7 +100,8 @@ const uploadPlaceholder = new Plugin({ subtitle.className = "subtitle"; subtitle.innerText = "Uploading…"; - ReactDOM.render(, icon); + const root = createRoot(icon); + root.render(); element.appendChild(icon); element.appendChild(title); diff --git a/shared/editor/nodes/Notice.tsx b/shared/editor/nodes/Notice.tsx index f63f6b2ed9..5c85f630a0 100644 --- a/shared/editor/nodes/Notice.tsx +++ b/shared/editor/nodes/Notice.tsx @@ -1,10 +1,10 @@ +import { createRoot } from "react-dom/client"; import { Token } from "markdown-it"; import { WarningIcon, InfoIcon, StarredIcon, DoneIcon } from "outline-icons"; import { wrappingInputRule } from "prosemirror-inputrules"; import { NodeSpec, Node as ProsemirrorNode, NodeType } from "prosemirror-model"; import { Command, EditorState, Transaction } from "prosemirror-state"; import * as React from "react"; -import ReactDOM from "react-dom"; import { Primitive } from "utility-types"; import toggleWrap from "../commands/toggleWrap"; import { MarkdownSerializerState } from "../lib/markdown/serializer"; @@ -107,7 +107,8 @@ export default class Notice extends Node { icon = document.createElement("div"); icon.className = "icon"; - ReactDOM.render(component, icon); + const root = createRoot(icon); + root.render(component); } return [