[英]Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. ReactJS
Can't resolve this issue. 无法解决此问题。 Whenever I import Layout I get the error above.
每当我导入布局时,都会出现上述错误。 When I import other components they work just fine.
当我导入其他组件时,它们工作正常。 At first I thought the name Layout was reserved so I changed it but still got the same error.
起初,我认为Layout是保留名称,所以我对其进行了更改,但仍然遇到相同的错误。
App.js App.js
import React, { Component } from 'react';
import Layout from "./components/Layout/Layout";
class App extends Component {
render() {
return (
<div>
<Layout />
</div>
)
}
}
export default App
Layout.js Layout.js
import React, { Component } from 'react'
import Footer from '../Footer/Footer'
import Quotes from '../Quotes/Quotes'
import './Layout.css'
class Layout extends Component {
render() {
return (
<div className='bgImg'>
<div className='centered text-center align-items-center justify-content-center'>
<Quotes />
</div>
<Footer />
</div>
)
}
}
export default Layout
The error tells you exactly what you should do. 该错误告诉您确切应该做什么。
First, make you sure export the components properly: 首先,请确保正确导出组件:
/* relevant imports */
class Quotes extends Component {
/* component code */
}
export default Quotes
Second make you use the proper import semantic in your Layout
component: 其次,使您在
Layout
组件中使用正确的导入语义:
import Quotes from '/path/to/your/component';
instead of 代替
import {Quotes} from '/path/to/your/component';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.