ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

❤ React报错问题分析

2026/9/25 11:18:45 拓冰建站 浏览量
❤ React报错问题分析

❤ React报错问题分析

❤️ You passed a second argument to root.render(…) but it only accepts one argument.

在这里插入图片描述

You passed a second argument to root.render(…) but it only accepts one argument.

react-dom.development.js:86 Warning: You passed a second argument to root.render(…) but it only accepts one argument.

♥ 原因

导入两个组件,需要将两个组件放在一个容器内

const root = ReactDOM.createRoot(document.getElementById('root'))
root.render(<><Header></Header>,<Footer></Footer></>
);

❤️ ‘react-scripts’ is not recognized as an internal or external command,operable program or batch file.

npm start 运行项目遇见:
在这里插入图片描述

原因:
有一些问题npm install无法完成 React 脚本的安装。按照这些简单的步骤来让它工作

解决方法一:

删除 node_modules 文件夹
删除 package-lock.json 文件
跑 npm install   //yarn install
跑 npm i -S react-scripts //yarn add -S react-scripts
跑 npm start //yarn start