chore: Upgrade to React 18 (#495)

* chore: Upgrade to React 18

* runfix: Add children type to FC components

* chore: Remove @types/react
This commit is contained in:
Tatius Titus
2023-04-07 08:29:44 +03:30
committed by GitHub
parent ba0a59629b
commit d2cd3ec879
8 changed files with 56 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
import ReactDOM from "react-dom";
import { createRoot } from "react-dom/client";
import { ReactNode, useState } from "react";
import { Box, IconButton, Slide, Snackbar, Typography } from "@mui/material";
import { Close, CheckCircleRounded, ErrorRounded } from "@mui/icons-material";
@@ -77,13 +77,14 @@ export const Notice: NoticeInstance = (props) => {
const container = document.createElement("div");
parent.appendChild(container);
const root = createRoot(container);
const onUnmount = () => {
const result = ReactDOM.unmountComponentAtNode(container);
if (result && parent) setTimeout(() => parent.removeChild(container), 500);
root.unmount();
if (parent) setTimeout(() => parent.removeChild(container), 500);
};
ReactDOM.render(<NoticeInner {...props} onClose={onUnmount} />, container);
root.render(<NoticeInner {...props} onClose={onUnmount} />);
};
(["info", "error", "success"] as const).forEach((type) => {