Topic: File path
mainman100 asked 6 years ago
Jakub Mandra staff premium answered 6 years ago
Hello,
It's because React have to compile first, so if you want to use image or something from your local files you have to import that.
And for this case all paths (like your assets) have to be inside /src folder.
In your particular case it should look like this:
Structure: >src >assets -image.jpg >components App.js Code: import React, { Component } from 'react'; import image from './../assets/image.jpg'; class App extends Component { render(){ return( <div> <img src={image}a alt="Your image" /> >/div> ); } } export default App;
Best regards,
Jakub from MDB
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB React
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No