Skip to content

Commit

Permalink
Replace deprecated ReactDOM methods in toastCreateAsyncExample
Browse files Browse the repository at this point in the history
  • Loading branch information
ggdouglas committed Jan 9, 2025
1 parent 8df9659 commit ede3048
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import * as React from "react";
import ReactDOM from "react-dom";
import ReactDOM from "react-dom/client";

import { Button, Intent, OverlayToaster } from "@blueprintjs/core";
import { Example } from "@blueprintjs/docs-theme";
Expand Down Expand Up @@ -76,7 +76,7 @@ async function showMessageFromNewToaster() {
// Wait for the message to fade out before completely unmounting the OverlayToaster.
await sleep(1_000);

unmountReact16Toaster(container);
unmountToaster(container);
document.body.removeChild(container);
}

Expand All @@ -88,12 +88,13 @@ async function showMessageFromNewToaster() {
/**
* @param containerElement The container argument passed to OverlayToaster.create/OverlayToaster.createAsync
*/
function unmountReact16Toaster(containerElement: HTMLElement) {
function unmountToaster(containerElement: HTMLElement) {
const toasterRenderRoot = containerElement.firstElementChild;
if (toasterRenderRoot == null) {
throw new Error("No elements were found under Toaster container.");
}
ReactDOM.unmountComponentAtNode(toasterRenderRoot);
const root = ReactDOM.createRoot(toasterRenderRoot);
root.unmount();
}

function sleep(ms: number) {
Expand Down

0 comments on commit ede3048

Please sign in to comment.