我的 codesandbox 出现 "Target container is not a DOM element" 错误,其中包含 react & parcel
I've got "Target container is not a DOM element" error on my codesandbox with react & parcel
我的项目在我的电脑上运行,但现在在 CodeSanbox
我遇到了一个错误
Target container is not a DOM element
该项目只是使用 react
& parcel
的模板项目。
我的家庭项目和 codesanbox 上的项目之间没有任何改变。
<!DOCTYPE html>
<html>
<head>
<title>React App w/ Parcel</title>
<meta charset="utf-8" />
</head>
<body>
<div id="app"></div>
<script src="index.js"></script>
</body>
</html>
import React from "react";
import ReactDOM from "react-dom";
import "./styles.scss";
const App = () => {
return <div />;
};
ReactDOM.render(<App />, document.getElementById("app"));
似乎与关键字 app
有冲突。
您可以简单地将 div 重命名为 root
或类似的
<!DOCTYPE html>
<html>
<head>
<title>React App w/ Parcel</title>
<meta charset="utf-8" />
</head>
<body>
<div id="root"></div>
<script src="index.js"></script>
</body>
</html>
import React from "react";
import ReactDOM from "react-dom";
import "./styles.scss";
const App = () => {
return <div />;
};
ReactDOM.render(<App />, document.getElementById("app"));
我的项目在我的电脑上运行,但现在在 CodeSanbox
我遇到了一个错误
Target container is not a DOM element
该项目只是使用 react
& parcel
的模板项目。
我的家庭项目和 codesanbox 上的项目之间没有任何改变。
<!DOCTYPE html>
<html>
<head>
<title>React App w/ Parcel</title>
<meta charset="utf-8" />
</head>
<body>
<div id="app"></div>
<script src="index.js"></script>
</body>
</html>
import React from "react";
import ReactDOM from "react-dom";
import "./styles.scss";
const App = () => {
return <div />;
};
ReactDOM.render(<App />, document.getElementById("app"));
似乎与关键字 app
有冲突。
您可以简单地将 div 重命名为 root
或类似的
<!DOCTYPE html>
<html>
<head>
<title>React App w/ Parcel</title>
<meta charset="utf-8" />
</head>
<body>
<div id="root"></div>
<script src="index.js"></script>
</body>
</html>
import React from "react";
import ReactDOM from "react-dom";
import "./styles.scss";
const App = () => {
return <div />;
};
ReactDOM.render(<App />, document.getElementById("app"));