SpreadJS V15.2中对React 与 Angular 框架进行了增强,支持了React 18 与 Angular 14
React 18
React18有一个新的ReactDOM Render API。升级React 18时,需要导入“ReactDOM/client”并使用新的 ReactDOM API,否则控制台将报告警告。
安装React 18
- npm install react react-dom
- //or if you are using yarn
- yarn add react react-dom
复制代码
更新Client Rendering APIs
首次安装React 18时,会将在控制台中看到如下警告:
ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it’s running React 17. Learn more: https://reactjs.org/link/switch-to-createroot
要消除此警告,需要使用新的renderAPI,以下是新版本与旧版本的对比:
旧版本:
- import { render } from 'react-dom';
- const container = document.getElementById('app');
- render(<App tab="home" />, container);
复制代码 新版本:
- import { createRoot } from 'react-dom/client';
- const container = document.getElementById('app');
- const root = createRoot(container);
- root.render(<App />);
复制代码 其余使用方式与之前相同。
Angular 14
无论是SpreadJS还是在线表格编辑器均可以在Angular 14上正确运行。
升级Angular 14
在终端中输入“ng update”并执行,然后ng将检查要更新的包。
- > ng update
- We analyzed your package.json, there are some packages to update:
-
- Name Version Command to update
- --------------------------------------------------------------------------------
- @angular/cli 13.3.8 -> 14.0.3 ng update @angular/cli
- @angular/core 13.3.11 -> 14.0.3 ng update @angular/core
-
- There might be additional packages which don't provide 'ng update' capabilities that are outdated.
- You can update the additional packages by running the update command of your package manager.
复制代码 然后运行“ng update@angular/cli”将angular更新为v14。
PS:如果提示升级不成功,请将 node 版本升级到14.15.0或更高版本。
|
|