I have two components ‘footer’ and ‘header’ in the components directory. It imports properly but I am not able to display it.
App.js
import header from "./components/header";
import footer from "./components/footer";
function App() {
return (
<>
<header />
<main>
<h1>Welcome to Proshop</h1>
</main>
<footer />
</>
)
}
export default App;
header.js
import React from 'react'
function header() {
return (
<div>header</div>
)
}
export default header
footer.js
import React from 'react'
function footer() {
return (
<div>footer</div>
)
}
export default footer
The output is just this
>Solution :
Your components must start with a capital letter, if not they will be treated like a regular html tags, see the docs on this
When an element type starts with a lowercase letter, it refers to a built-in component like or and results in a string ‘div’ or ‘span’ passed to React.createElement. Types that start with a capital letter like compile to React.createElement(Foo) and correspond to a component defined or imported in your JavaScript file.
