I am able to import the svg in the parent component App.js(in the src folder) but not in the child component Home.js(src/components/Home.js)
When I import directly into the parent component the svg displays perfectly but if I import in the child component it says
Module not found: Can't resolve './img/BulbOn.svg' in 'E:\Website Work\Current Work\parsa_ventures\src\components'
import './App.css'
import Home from './components/Home'
function App() {
return (
<div>
<Home />
</div>
)
}
export default App
import BulbOn from './img/BulbOn.svg'
class Home extends React.Component {
render() {
return (
<div>
<img src={BulbOn} alt="text" />
</div>
)
}
}
export default Home
I am new to react so I am wondering if I can easily import svg in child component without having to use props.
my folder structure paths,
Website Work/Current Work/parsa_ventures/src/App.js (Parent)
Website Work/Current Work parsa_ventures/src/components/Home.js (Child) Website Work/Current Work/parsa_ventures/src/img/BulbOn.svg (Image)
i put the react boilerplate inside parsa_ventures, so thats where the src is containing all the files