fix(amis-saas-8226): render方式改用react18方法

Change-Id: I6bba95700d2262bc074c5a51f8147d95b329f400
This commit is contained in:
wibetter 2022-11-30 12:15:00 +08:00
parent 3978e53e6c
commit c6131f1d83
2 changed files with 7 additions and 12 deletions

View File

@ -41,7 +41,6 @@
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^8.3.2",
"@svgr/rollup": "^6.2.1",
"@svgr/webpack": "^5.5.0",
"@types/async": "^2.0.45",
"@types/classnames": "^2.2.3",
"@types/codemirror": "^5.60.5",
@ -90,12 +89,7 @@
"stylelint": "^14.11.0",
"ts-loader": "^9.2.5",
"tslib": "^2.3.1",
"typescript": "^4.4.2",
"webpack": "^5.52.1",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-cli": "^4.8.0",
"webpack-node-externals": "^3.0.0",
"webpack-react-i18n": "0.0.10"
"typescript": "^4.4.2"
},
"peerDependencies": {
"amis": "*",

View File

@ -2,6 +2,7 @@ import {observer} from 'mobx-react';
import {isAlive} from 'mobx-state-tree';
import React from 'react';
import {unmountComponentAtNode} from 'react-dom';
import {createRoot} from 'react-dom/client';
import {EditorManager} from '../manager';
import {EditorStoreType} from '../store/editor';
import {autobind, guid} from '../util';
@ -154,12 +155,12 @@ export function mountInIframe(
}
const bridgeName = location.hash.substring(1);
reactDom.render(
<PreviewWrapper bridgeName={bridgeName} envCreator={envCreator} />,
dom
);
const root = createRoot(dom);
root.render(<PreviewWrapper bridgeName={bridgeName} envCreator={envCreator} />);
window.onunload = function () {
unmountComponentAtNode(dom);
// unmountComponentAtNode(dom);
root.unmount(); // react18
};
}