- #1
mathmari
Gold Member
MHB
- 5,049
- 7
pbuk said:However you can also do this, described at https://create-react-app.dev/docs/adding-images-fonts-and-files, which has advantages (notably if logo.png is small enough it will be inlined instead of referenced which makes your site load faster).
Now write your component as:Code:# Set up your files like this assets/img/logo.png src/ui-component/Logo.js
JavaScript:// Not sure if you need this but it is in the boilerplate in the docs. import React from 'react'; // We need a relative reference from the location of this file. import logo from '../assets/img/logo.png'; function Header() { return <img src={logo} alt="Logo" />; } export default Header;
It works with this code! If I want to write a text next to the image do I use <div> ?
I mean :
Code:
return <div><div><img src={logo} alt="Logo" width="40" /></div><div>Title</div></div>;
![Thinking face :thinking: 🤔](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f914.png)