I was just learning React fundamentals and then I got this problem:
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. Check the render method of
App
.
I looked at everything and I don't know if I got something wrong there because I can't see any errors at all. Saw some problems like this but couldn't solve my own one :D here is some code
index.js:
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(<App />,document.getElementById('root'));
app.js:
import React from "react";
import Footer from "./components/Footer";
import MainContent from "./components/MainContent";
import Navbar from "./components/Navbar";
function App() {
return (
<div>
<Navbar />
<MainContent />
<Footer />
</div>
)
}
export default App
Navbar.js:
import React from 'react';
function Navbar() {
return (
<nav>This is a Navbar</nav>
)
}
export default Navbar
MainContent.js:
import React from 'react';
function MainContent() {
return (
<main>This is a footer</main>
)
}
export default MainContent
Footer.js:
import React from 'react';
function Footer() {
return (
<footer>This is a footer</footer>
)
}
export default Footer