My component with Home is not accessible in my App.js component. Home.jsx
import React from 'react'
import "./Home.scss
const Home = () => {
return (
<div>
<div className="home">Home</div>
</div>
)
}
export default Home
This is my App.js Code
import "./pages/home/Home"
function App() {
return (
<div className="App">
<Home/>
</div>
);
}
export default App;
I am facing the error:
[eslint]
src/App.js
Line 8:6: 'Home' is not defined react/jsx-no-undef
Search for the keywords to learn more about each error.
ERROR in [eslint]
src/App.js
Line 8:6: 'Home' is not defined react/jsx-no-undef
Search for the keywords to learn more about each error.
webpack compiled with 1 error
I am expecting to access Home component in App.js file
Add reference when you file import like this
import Home from "./pages/home/Home";
In App.js your import should be
import Home from "./pages/home/Home"
Then you can use it
try
import Home from "./pages/home/Home"
if next time you are not using export default, you need to do destructuring
import {moduleA, moduleB} from "./pages/home/Home"
assume you are exporting moduleA and moduleB without export default keyword
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.