为什么这么麻烦
Why the Dance?
Loading...
Why the Dance?
过时的语法
在这个视频中,我涂鸦了一些看起来像这样的代码:
ReactDOM.render(<App />);我在这里暴露了我的年龄 😅 这就是我们以前渲染 React 应用的方式,但在 React 18 中发生了变化。应该是这个:
import { createRoot } from "react-dom/client";
const root = createRoot(container);
root.render(<App />);请放心,我们在课程早些时候讲解这个过程时使用了正确/现代的语法。对造成的任何困惑表示歉意!