1
我有2個主要文件「app.jsx」和「Layout.jsx」。當我在我的「app.jsx」中定義我的Layout組件時,它成功呈現。但是,當我將它移動到「Layout.jsx」並從「app.jsx」中請求時,它不起作用。 這裏是我的代碼:我不能在我的項目中導入帶有webpack的React組件
「Layout.jsx」
module.exports = class Layout extends React.Component {
render() {
return(
<h3>Layout Component</h3>
)
}
}
「app.jsx」
const React = require("react");
const ReactDOM = require("react-dom");
const Layout = require("./pages/Layout.jsx");
const App = document.getElementById("app");
ReactDOM.render(<Layout />, App);
什麼是錯在我的代碼?
什麼是你正在向layout.jsx後收到的錯誤? –
Webpack只是成功捆綁了文件,但是當我查看Firefox的React調試工具時,我看到以下消息:「等待根加載...」 –
您是否對layout.jsx文件導入了反應? –