mirror of
https://github.com/outline/outline.git
synced 2026-11-24 23:00:18 +03:00
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
This commit is contained in:
1 parent
84bc70dfd8
commit
1cf9d4c6cb
4 files changed
+12
-8
No files matched your search
@@ -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(<PlusIcon />, button);
|
||||
const root = createRoot(button);
|
||||
root.render(<PlusIcon />);
|
||||
|
||||
return [
|
||||
...super.plugins,
|
||||
|
||||
+3
-2
@@ -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) {
|
||||
</StrictMode>
|
||||
);
|
||||
|
||||
render(<App />, element);
|
||||
const root = createRoot(element);
|
||||
root.render(<App />);
|
||||
}
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
|
||||
@@ -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(<FileExtension title={action.add.file.name} />, icon);
|
||||
const root = createRoot(icon);
|
||||
root.render(<FileExtension title={action.add.file.name} />);
|
||||
|
||||
element.appendChild(icon);
|
||||
element.appendChild(title);
|
||||
|
||||
@@ -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 [
|
||||
|
||||
Reference in new issue
Block a user